amcharts4不是用angular 6编译的



在包含amcharts4时,我在编译应用程序时遇到了问题。我只是简单地安装了amcharts4npm包,并试图在我创建的组件中使用它。CLI配置是否缺少某些内容?

ERROR in node_modules/@amcharts/amcharts4/.internal/core/utils/Object.d.ts(60,117): error TS2536: Type 'Key' cannot be used to index type 'Object'.
node_modules/@amcharts/amcharts4/.internal/core/utils/Object.d.ts(67,109): error TS2536: Type 'Key' cannot be used to index type 'Object'.
node_modules/@amcharts/amcharts4/.internal/core/utils/Object.d.ts(76,116): error TS2536: Type 'Key' cannot be used to index type 'Object'.
node_modules/@amcharts/amcharts4/.internal/core/utils/Type.d.ts(25,32): error TS2304: Cannot find name 'Extract'.

我的打字稿:

import { Component, NgZone } from "@angular/core";
import * as am4core from "@amcharts/amcharts4/core";
import * as am4charts from "@amcharts/amcharts4/charts";
import am4themes_animated from "@amcharts/amcharts4/themes/animated";
am4core.useTheme(am4themes_animated);

@Component({
selector: 'app-am-charts',
templateUrl: './am-charts.component.html',
styleUrls: ['./am-charts.component.css']
})
export class AmChartsComponent {
}

根据这个问题这个较新的已关闭问题和我们的角度集成文档,请确保您的tsconfig.json中有以下内容,因为AmCharts 4目前不支持严格模式:

{
"compilerOptions": {
"strictNullChecks": false,
"strictFunctionTypes": false
}
}

除此之外,请确保您至少使用TypeScript版本2.72.8,但不是3.x,因为它还不受支持。

使用忽略打字脚本代码错误的@ts-ignore工作站:

// @ts-ignore
import * as am4core from "@amcharts/amcharts4/core";
// @ts-ignore
import * as am4charts from "@amcharts/amcharts4/charts";

并将打字脚本版本更新为最新版本:

npm install typescript@next --save

对我来说是:"typescript": "^3.4.0-dev.20190220"

最新更新