我们正在将 WebStorm 与 TypeScript 项目结合使用。我们已经使用 tsconfig.json 正确配置了项目,因为命令行中的一切都正常工作。
但是,当在 WebStorm 中打开项目时,它会就地编译 ts 文件(它会在与相应 ts 文件相同的文件夹中生成 js 文件),正如 tsconfig 所说,它应该位于 dist
目录中。
例如,在下面的屏幕截图中,evaluator.js
与 evaluator.ts
文件位于同一文件夹中。知道如何配置 WebStorm 使其不会就地生成 js 文件吗?
以下是 Typescript 首选项。
这是 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/