我獨自跟着VS Code typescript配置。如何在VScode中設置打字稿?
https://code.visualstudio.com/Docs/languages/typescript
我安裝我的tsconfig.json像
{
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"outFile": "built/local/tsc.js",
"sourceMap": true
},
"include": [
"**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
,我的任務運行
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "always",
"problemMatcher": "$tsc"
}
我的TS碼
class StartUp {
public static main(): number {
console.log('Helle Workd');
return 5;
}
}
console.log('test');
StartUp.main();
對於一些reaso n,當我按下cmd + shift + B(build)時,在輸出窗口中看不到任何輸出。我確實看到如下錯誤:
hello.ts(8,1): error TS2304: Cannot find name 'ddd'.
如果我在代碼中隨機添加ddd字符串。
有人可以幫我解決這個問題嗎?非常感謝!
是生成的文件好嗎?也許你可以運行「tsc -p」。在控制檯。如果沒有錯誤,命令將不會輸出。 – Yuan