Incorporating Angular 8 (initiated a project in Visual Studio 2019) and currently working with a fabric.init.ts
file containing the following content:
import 'fabric';
import * as fabric from 'fabric/fabric-impl';
// (TS) Property 'DPI' does not exist on type 'typeof import(..@types/fabric/fabric-impl)'
fabric.DPI = 213;
....
The following code aligns well with the d.ts definition:
// Override fabric to meet our requirements
fabric.util.object.extend(fabric.Object.prototype, {
centeredRotation: true,
How can I disregard the TS2339 error related to DPI
? Having autocomplete functionality is crucial for mastering fabric.
This is how my package.json looks like:
"private": true,
"dependencies": {
"@angular/core": "8.2.14",
....
"@angular/router": "8.2.14",
"@types/fabric": "3.5.1",
"fabric": "3.5.1",
...
},
UPDATE
To address this issue temporarily, I have included this line:
// @ts-ignore
fabric.DPI = 213;
While not the ideal solution, I am inclined towards @wentjun's approach.
By modifying this line:
import * as fabric from 'fabric/fabric-impl';
to import { fabric } from 'fabric';
, I now benefit from VisualStudio intellisense support. Naturally, I have added @types/fabricjs to my package.json file.