问题
I'm having trouble with compiling my app when including amcharts4. I have simply installed the amcharts4 npm package and am trying to use it in a component i've created. Am i missing something with the CLI config?
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'.
my typescript:
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 {
}
回答1:
Per this issue this newer closed issue and our angular integration documentation, make sure you have the following in your tsconfig.json as AmCharts 4 does not currently support strict mode:
{
"compilerOptions": {
"strictNullChecks": false,
"strictFunctionTypes": false
}
}
In addition to this, make sure you're at least on TypeScript version 2.7 2.8 but not 3.x as it isn't supported yet.
回答2:
Use @ts-ignore
anotation which ignores errors in typescript code:
// @ts-ignore
import * as am4core from "@amcharts/amcharts4/core";
// @ts-ignore
import * as am4charts from "@amcharts/amcharts4/charts";
And update typescript version for example to newest:
npm install typescript@next --save
For me it was: "typescript": "^3.4.0-dev.20190220"
来源:https://stackoverflow.com/questions/53416341/amcharts4-is-not-compiling-with-angular-6