【发布时间】:2017-08-05 20:19:40
【问题描述】:
我在应用程序中添加了包 @types/underscore,并将 ts 包更新为 2.4.2 版本,但如果我尝试编译,我会收到错误信息:
node_modules\@types\underscore\index.d.ts(8,1): error TS1128: Declaration or statement expected.
node_modules\@types\underscore\index.d.ts(8,11): error TS1005: ';' expected.
node_modules\@types\underscore\index.d.ts(8,22): error TS1005: '{' expected.
对应
export as namespace _;
这些是 ts 参数:
.pipe(tsc({
target: 'ES6',
declarationFiles: false,
noExternalResolve: true,
inlineSources: true,
inlineSourceMap: true,
types: [ "underscore", "cordova-plugin-camera" ]
}))
我错过了什么?
【问题讨论】:
-
我无法重现您遇到的错误。你是如何安装下划线类型的? IE。您是否使用
npm install @types/underscore来做到这一点?你是如何构建 TypeScript 的? IE。例如,您是否使用 gulp-typescript?您是否尝试过直接使用 TypeScripttsc编译器从命令行构建 TypeScript? -
看起来问题是我也必须更新 gulp-typescript。现在我没有这个错误了
-
这里有同样的错误,但在我看来,问题存储在 node_modules 文件夹中。我试图让我的项目启动它给出与上述相同的错误。但我复制粘贴了一些项目正在运行的项目,它运行良好。 git ignore 文件忽略 node_modules 文件夹。对不起,我写得不好。
标签: typescript underscore.js gulp-typescript