Recently started learning JavaScript and I am interested in rotating, changing scale of images on canvas and coding in TypeScript using Fabric.js. As the import method for TypeScript differs from JavaScript, I am looking for guidance on how to import it into TypeScript. Any helpful links would be appreciated.
I installed it using npm
install --save @types/fabric
import {fabric} from 'fabric';
However, after running grunt files to compile to JavaScript, I encountered the following error:
MacBook-Pro:someName mmmr$ grunt
(node:3965) ExperimentalWarning: The http2 module is an experimental API.
Running "typescript:test" (typescript) task
> src/someName.ts(20,26): error TS1147: Import declarations in a namespace cannot reference a module.
> src/someName.ts(20,26): error TS2307: Cannot find module 'fabric'.
> src/import.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
> src/import.ts(1,24): error TS2307: Cannot find module 'fabric'.
Warning: Task "typescript:test" failed. Use --force to continue.
Aborted due to warnings.
Can anyone provide solutions to fix this issue?