【发布时间】:2020-04-25 02:48:10
【问题描述】:
我正在使用 Angular 8(在 Visual Studio 2019 中启动了一个项目)并拥有带有下一个内容的 fabric.init.ts 文件:
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;
....
下一步就ok了,因为它符合d.ts定义:
// Override fabric to meet ourrequirements
fabric.util.object.extend(fabric.Object.prototype, {
centeredRotation: true,
如何忽略DPITS2339 错误。有自动补全功能真的很棒,特别是用于学习结构。
我的 package.json:
"private": true,
"dependencies": {
"@angular/core": "8.2.14",
....
"@angular/router": "8.2.14",
"@types/fabric": "3.5.1",
"fabric": "3.5.1",
...
},
编辑
现在我通过添加这一行来解决它:
// @ts-ignore
fabric.DPI = 213;
我知道这不是最好的解决方案,我更喜欢@wentjun 的解决方案。
通过更改:import * as fabric from 'fabric/fabric-impl'; 到 import { fabric } from 'fabric'; 我现在也启用了 VisualStudio 智能感知。当然,我在 package.json 中添加了 @types/fabricjs。
【问题讨论】:
标签: angular typescript fabricjs