在VSCode上调试TypeScript

时间:2015-11-04 13:44:54

标签: debugging typescript visual-studio-code

我正在尝试使用Visual Studio代码调试以下打字稿代码:

class Student {
    fullname : string;
    constructor(public firstname, public middleinitial, public lastname) {
        this.fullname = firstname + " " + middleinitial + " " + lastname;
    }
}

interface Person {
    firstname: string;
    lastname: string;
}

function greeter(person : Person) {
    return "Hello, " + person.firstname + " " + person.lastname;
}

var user = new Student("Jane", "M.", "User");

console.log(greeter(user));

这是我的launch.json配置文件:

{
    "version": "0.1.0",
    // List of configurations. Add new configurations or edit existing ones.
    "configurations": [
        {
            // Name of configuration; appears in the launch configuration drop down menu.
            "name": "TypeScriptDebugTest",
            // Type of configuration.
            "type": "node",
            // Workspace relative or absolute path to the program.
            "program": "./HelloWorld.ts",
            // Automatically stop program after launch.
            "stopOnEntry": false,
            // Command line arguments passed to the program.
            "args": [],
            // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
            "cwd": ".",
            // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
            "runtimeExecutable": null,
            // Optional arguments passed to the runtime executable.
            "runtimeArgs": ["--nolazy"],
            // Environment variables passed to the program.
            "env": {
                "NODE_ENV": "development"
            },
            // Use JavaScript source maps (if they exist).
            "sourceMaps": true,
            // If JavaScript source maps are enabled, the generated code is expected in this directory.
            "outDir": "./built"
        }
    ]
}

javascript编译的文件位于根目录下的内置文件夹中。当我尝试调试时,同样的错误会一直发生:"无法连接到运行时进程(5000ms后超时)"

注意:我想调试.ts文件,而不是编译的javascript。

有谁知道如何解决这个问题?

谢谢!

1 个答案:

答案 0 :(得分:0)

我们的下一个版本将支持调试节点4.x.请继续关注!