Reputation: 45
I am tyring to start my angular project by doing ng s but its giving error because of some variables which are defined at window object.
var chart=window.Highcharts.chart()
Property 'Highcharts' does not exist on type 'Window'.
When i modify any file it will compile successfully automatically.
I want to ignore those errors at intial start?
Upvotes: 0
Views: 54
Reputation: 2476
You may need to import Highcharts as given below
import * as Highcharts from 'highcharts';
Once imported, you can invoke chart method as Highcharts.chart
ngOnInit(){
Highcharts.chart('container', this.options);
}
You don't need call window.Highcharts
Reference: https://www.highcharts.com/blog/post/highcharts-and-angular-7/
Upvotes: 1
Reputation: 71961
You should install the typings from HighCharts:
npm i -D @types/highcharts
Or update to version 7 of HighCharts which has TypeScript
support included. With that version you can just import highcharts like this:
import * as Highcharts from 'highcharts';
If that doesn't work, you can also update the global window object declaration with your own properties. You should add this to either the main.ts
or the polyfills.ts
of your application:
declare global { interface Window { HighCharts: any; } }
Upvotes: 2