Reputation: 1792
I'm using fabric-with-gestures in my Typescript application and everything is fine.
However, the original library fabric has types defined and I can install them with npm install --dev @types/fabric
but Typescript doesn't recognize them for the fabric-with-gestures
package.
How could I use the typings from fabric
together with fabric-with-gestures
as there is no module @types/fabric-with-gestures
and I'm assuming that the types are mostly the same?
Is this even possible?
Upvotes: 2
Views: 180
Reputation: 74490
For all packages in general, you can create a type alias by adding baseUrl
and paths
options to your tsconfig.json (I don't use fabric
, but a quick setup just did compile successfully).
tsconfig.json:
{
"compilerOptions": {
...
// absolute name imports are resolved relative to baseUrl
"baseUrl": ".",
// alias "fabric-with-gestures" is mapped to path of fabric @types
"paths": {
"fabric-with-gestures": ["node_modules/@types/fabric"]
}
}
}
Usage:
// Use fabric-with-gestures. Types are internally mapped to @types/fabric
import { fabric } from "fabric-with-gestures";
Upvotes: 4