angular - ng serve 导致错误:“不能将命名空间用作类型”
问题描述
尝试使用 ng serve 编译应用程序时,出现以下错误:
ERROR in ../node_modules/highcharts-angular/lib/highcharts-chart.component.d.ts(3,58): error TS2709: Cannot use namespace 'OnDestroy' as a type.
../node_modules/highcharts-angular/lib/highcharts-chart.component.d.ts(13,19): error TS2709: Cannot use namespace 'EventEmitter' as a type.
../node_modules/highcharts-angular/lib/highcharts-chart.component.d.ts(14,20): error TS2709: Cannot use namespace 'EventEmitter' as a type.
../node_modules/highcharts-angular/lib/highcharts-chart.component.d.ts(17,21): error TS2709: Cannot use namespace 'ElementRef' as a type.
../node_modules/highcharts-angular/lib/highcharts-chart.component.d.ts(17,40): error TS2709: Cannot use namespace 'NgZone' as a type.
这里可能是什么问题?我没有找到解决办法。
版本:
最新的 Highcharts 版本
Angular:我使用的是 Angular 7.1.3。本地和全球 8.1.0
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { HighchartsChartModule } from 'highcharts-angular';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HighchartsChartModule,
HttpModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
解决方案
要以 Angular 运行 highcharts,我们必须同时安装 highcharts 和 highcharts-angular。
"highcharts-angular": "^2.4.0",
"highcharts": "^7.1.2"
推荐阅读
- javascript - NextJS routeChangeComplete 不会在 _app.js 上触发
- flutter - 如何在 Flutter 中为 appbar 标题设置默认文本样式?
- java - DocumentBuilder.class 运算符在 System Classloader 中加载类
- java - 使用 Android Studio 获取每日使用情况统计信息
- javascript - 在javascript中的嵌套foreach中访问子元素中的父索引
- flot - Oracle APEX 5.0:折线图上的标签
- function - &rest in common lisp
- hive - Hive:如何消除重复的子字符串
- visual-studio-code - 在 VsCode 中使用 Windows 文件对话框打开文件/文件夹
- xhtml - 修复了 DOCTYPE XHTML 上 TR/table 的显示