visual-studio - 在 Visual Studio 中编译 typescript 会出现错误 "Unexpected Token..."

标签 visual-studio typescript

我正在 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/

相关文章:

javascript - 在 Ionic 3 中使用 JavaScript 文件

javascript - 尽管使用setState(),但是状态更改后,React组件不会重新呈现

c# - 跨多个网站共享用户控件

c++ - 使用 Visual Studio 或 MingW 从 Unix 移植代码?

c# - 代码花费大部分时间的地方

node.js - 如何让 Webpack 和 Typescript 使用外部 node_module 文件夹?

javascript - TypeScript:库函数的返回类型未知时该怎么办

visual-studio - visual studio 2017 spa 模板 vue js 丢失

c++ - 类型 "const char *"的 arg 与类型 "LPSTR"c++ 的参数不兼容

javascript - 父组件中的对象属性发生变化时,如何更新子组件中的对象