我正在 Visual Studio 2013 更新 5 中处理大型复杂节点项目。我安装了 tsc 版本 1.8.5,但在我的系统上找不到任何其他版本的引用。当我使用“tsc --module commonjs”在命令行上编译时,程序编译得很干净。
当我在 visual studio 中编译时出现错误
Build: Unexpected token; 'module, class, interface, enum, import or statement expected'
标记的文件是 express.d.ts。
这会阻止我运行调试器,即使我可以在命令行上进行编译。是不是VS配置有问题?
詹姆斯
最佳答案
考虑到有效的命令行,我打赌您需要修改您的 tsconfg.json
下面的导入位显然是 "module": "commonjs"
这是一个完整的“标准”tsconfig 文件,用于 Typings v1.0.0 或更高版本。
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"pretty": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
"noFallthroughCasesInSwitch": true
},
"exclude": [
"node_modules",
"typings/index.d.ts",
"typings/modules"
],
"compileOnSave": false
}
关于visual-studio - 在 Visual Studio 中编译 typescript 会出现错误 "Unexpected Token...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37463828/