我有一个使用 npm 管理的 Angular 2 项目,我最近运行了
typings install dt~jquery --save --global
将 JQuery 类型定义添加到我的项目中。
然后,npm 按预期将该类型定义文件下载到目录 node_modules 中。
现在的问题是 Typescript 编译器(使用 npm run tsc:w
)提示:
$ npm run tsc:w
node_modules/@types/jquery/index.d.ts(3246,5): error TS2300: Duplicate identifier 'export='. typings/globals/jquery/index.d.ts(601,5): error TS2374: Duplicate string index signature. typings/globals/jquery/index.d.ts(2850,5): error TS2374: Duplicate string index signature. typings/globals/jquery/index.d.ts(2851,5): error TS2375: Duplicate number index signature. typings/globals/jquery/index.d.ts(3224,5): error TS2300: Duplicate identifier 'export='. 18:48:59 - Compilation complete. Watching for file changes.
有什么想法可以解决这个问题吗?
最佳答案
转换器给出重复定义错误,因为您似乎已将定义文件安装到项目中的多个位置:
node_modules/@types/jquery/index.d.ts
typings/globals/jquery/index.d.ts
尝试通过键入以下行来卸载@types/jquery
模块:
npm remove @types/jquery --save-dev
关于jquery - 在 Angular 2 应用程序中集成 JQuery 后出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41269009/