How to correctly import TypeScript type definitions

Hello,

I’m playing around with bpmn-js and I’m using it in a TypeScript environment. How do I correctly import the already available TypeScript type definitions? I can see, that for example the Viewer is already defined in lib/Viewer.d.ts. But when I try to import it with import { Viewer } from 'bpmn-js/lib/Viewer' the TypeScript compiler tells me, that it cannot find the correspondig type declarations:

[tsl] ERROR in /home/node/project/bpmn/static/bpmn/index.ts(4,20)                                                                                                          
       TS2307: Cannot find module 'bpmn-js/lib/Viewer' or its corresponding type declarations.

Any hints what I’m doing wrong?

Thanks in advance,
Marc

I was basically doing the same thing but for React.

This is how I import types:

import BpmnViewer from 'bpmn-js/lib/Viewer';
import type eventBus from "bpmn-js/lib/Viewer"
import type InternalEvent from "bpmn-js/lib/Viewer"

See example: https://github.com/joey-kwl/React-Typescript-BPMN-example/blob/main/src/Bpmn.tsx