【发布时间】:2016-03-07 18:31:09
【问题描述】:
我已经安装了最新版本的 VS Code,并尝试编译“app.ts”文件,以便获得“app.js”和“app.js.map”。但是当我编译项目时,它只创建“app.js”文件,没有映射文件。
在我的根文件夹中,我有一个“.vscode”文件夹,其中包含以下“tsconfig.json”
{
"compilerOptions": {
"target": "es6",
"module": "amd",
"sourceMap": true
}
以及下面的“tasks.json”文件
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// args is the HelloWorld program to compile.
"args": ["app.ts"],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
}
在根目录中有我的“app.ts”文件
module App {
export class Person {
constructor(public name: string) { }
public log(showLog: boolean): void {
if (showLog) {
console.log("Der Name des Nutzers ist: " + this.name)
}
}
}
}
var person = new App.Person("Hallo Welt");
person.log(true);
但是当我用 ctrl+shift+b 编译它时,它只创建 app.js 文件,没有映射。
更新: 我也尝试过修改“tasks.json”
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// args is the HelloWorld program to compile.
"args": [" --sourcemap app.ts"],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
使用 --sourcemap 参数,但它不起作用。但是当我使用带有以下命令的命令提示符时:
c:\Temp\vsCode\tsc --sourcemap app.ts
然后一切正常并创建映射文件。
【问题讨论】:
标签: typescript visual-studio-code