2016-03-07 54 views
1

我已经安装了最新版本的VS Code,并尝试编译一个“app.ts”文件,以便获得“app.js”和“app.js.map”。但是当我编译这个项目时,它只会创建“app.js”文件并且不会创建映射文件。VS Code TypeScript SourceMap创建

在我的根文件夹

我有一个 “.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 FIL e并且没有映射。

更新: 我还试图修改 “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说法,但它不工作。但是当我使用命令promt与以下命令:

c:\Temp\vsCode\tsc --sourcemap app.ts 

然后一切工作正常,并创建映射文件。

回答

1

解决方案:修改指定参数时,它与字符串数组,似乎是一个解决方案

"args": ["--sourcemap", "app.ts"] 

替代的解决方案,当你想用你的tsconfig.json的编译选项,你需要使用此任务以.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", 

    "windows": { 
     "command": "tsc", 
     "isShellCommand": true 
    }, 

    // Tell the tsc compiler to use the tsconfig.json from the open folder. 
    "args": ["-p", "."], 

    // use the standard tsc problem matcher to find compile problems 
    // in the output. 
    "problemMatcher": "$tsc" 
} 

我已经修改了原来的职位,并增加了“窗口”的设置,如果没有这个设置似乎VS代码使用旧版本的打字稿1.0.3.0,但我不知道为什么。

解数3 - 尝试看看如果Windows PATH变量不具有进入打字稿1.0版 - 删除该条目,并添加到

2

我想你应该在根文件夹中有tsconfig.json(请参阅tsconfig)。不在.vscode文件夹中。

.vscode文件夹用于存储特定于可视化sudio代码(launch.json,settings.json,tasks.json)的配置文件。

+0

我同样的结果尝试了最新版本的条目没有创建映射文件 – squadwuschel