vs代码不转译ts文件
vs code not transpiling ts files
我安装了 Visual Studio 代码(版本 1.7.2)和打字稿 1.8。我在文件夹中构建了一个简单的 react-native 项目。 (反应应用程序工作得很好,就像我在调试器中 运行 它一样)。现在我尝试整合打字稿。但是 vs code 不会在保存 (ctrl+s) 或构建 (ctrl+b) 时转换我的代码。这是我的 tsconfig.json
文件(位于我的项目的根目录中):
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"noImplicitAny": true
},
"compileOnSave": true,
"exclude": [
"node_modules"
]
}
这里是 tasks.json
文件:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "always",
"problemMatcher": "$tsc"
}
编译发生得很好,因为 vs 代码能够从测试文件调用中找出语法错误 "mytest.ts"
但是在保存或构建时没有生成 "mytest.js" 文件。我已按照 https://code.visualstudio.com/Docs/languages/typescript
中的说明进行操作
我仍然无法让 vs code 转译我的代码。
任何帮助,对正确方向的提示将不胜感激。
提前致谢
我终于能够通过像这样修改 tasks.json
文件来解决我的问题:
{
...
"args": ["-p", "${workspaceRoot}"],
...
}
我安装了 Visual Studio 代码(版本 1.7.2)和打字稿 1.8。我在文件夹中构建了一个简单的 react-native 项目。 (反应应用程序工作得很好,就像我在调试器中 运行 它一样)。现在我尝试整合打字稿。但是 vs code 不会在保存 (ctrl+s) 或构建 (ctrl+b) 时转换我的代码。这是我的 tsconfig.json
文件(位于我的项目的根目录中):
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"noImplicitAny": true
},
"compileOnSave": true,
"exclude": [
"node_modules"
]
}
这里是 tasks.json
文件:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "always",
"problemMatcher": "$tsc"
}
编译发生得很好,因为 vs 代码能够从测试文件调用中找出语法错误 "mytest.ts" 但是在保存或构建时没有生成 "mytest.js" 文件。我已按照 https://code.visualstudio.com/Docs/languages/typescript
中的说明进行操作我仍然无法让 vs code 转译我的代码。
任何帮助,对正确方向的提示将不胜感激。
提前致谢
我终于能够通过像这样修改 tasks.json
文件来解决我的问题:
{
...
"args": ["-p", "${workspaceRoot}"],
...
}