typescript - WebStorm 就地编译 TypeScript 文件而不是生成到目标文件夹中

标签 typescript webstorm

我们正在将 WebStorm 与 TypeScript 项目结合使用。我们已经使用 tsconfig.json 正确配置了项目,因为命令行中的一切都正常工作。

但是,当在 WebStorm 中打开项目时,它会就地编译 ts 文件(它会在与相应 ts 文件相同的文件夹中生成 js 文件),正如 tsconfig 所说,它应该位于 dist 目录中。

例如,在下面的屏幕截图中,evaluator.jsevaluator.ts 文件位于同一文件夹中。知道如何配置 WebStorm 使其不会就地生成 js 文件吗?

enter image description here

以下是 Typescript 首选项。

enter image description here

这是 tsconfig.json 文件

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "charset": "utf-8",
    "declaration": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "dist",
    "pretty": false,
    "rootDir": "src",
    "sourceMap": true,
    "strict": true,
    "stripInternal": true,
    "target": "es2016",
    "typeRoots": ["node_modules/@types"],
    "types": ["node", "jest"],
    "lib": [
      "es2019"
    ]
  },
  "include": ["src/**/*.ts", "src/**/*.js", "src/index.ts"],
  "exclude": ["node_modules"]
}

最佳答案

Apparently Webstorm transpiles typescript files to javascript independently

Make sure that 'Enable TypeScript compiler' is disabled in Preferences | Languages & Frameworks | TypeScript, and that you don't have TypeScript file watcher set up in Preferences | Tools | File Watchers

关于typescript - WebStorm 就地编译 TypeScript 文件而不是生成到目标文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61733978/

相关文章:

html - 如何在 Angular 中创建实时更新的绑定(bind)文本输入?

javascript - 在 WebStorm 中运行/调试当前文件

angular - 如何触发带有 `create new component` 的新对话框

asynchronous - Angular 2 : Async pipe for array index

typescript - TSLint: 'from' 之前的空格太多(导入间距)

node.js - WebStorm - 自动完成

webstorm - 在 WebStorm 中调试 Cypress

angular - 如何将 angular2 服务注入(inject)单元测试? (RC3)

typescript - 如何让 typescript 方法回调在 VueJs 中工作?

typescript - 移相器 3 : Update Sprite object from canvas texture