VS Code TypeScript SourceMaps通过TSC不工作

Con*_*nel 5 javascript source-maps typescript tsc visual-studio-code

任何人都可以指出我正确的方向,为什么我不能在我的任何TS文件中击中任何断点请?该应用程序是Node.JS应用程序,并使用TSC进行转换.以下是条目app.ts文件的示例:

./src/app.ts

import 'reflect-metadata';

import kernel from './ioc'
import { IServer } from './utilities/abstract/IServer'

let server = kernel.get<IServer>("IServer");
server.start();
Run Code Online (Sandbox Code Playgroud)

./src/app.js

"use strict";
require('reflect-metadata');
var ioc_1 = require('./ioc');
var server = ioc_1.default.get("IServer");
server.start();

//# sourceMappingURL=app.js.map
Run Code Online (Sandbox Code Playgroud)

./src/app.js.map

{"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,QAAO,kBAAkB,CAAC,CAAA;AAE1B,oBAAmB,OACnB,CAAC,CADyB;AAG1B,IAAI,MAAM,GAAG,aAAM,CAAC,GAAG,CAAU,SAAS,CAAC,CAAC;AAC5C,MAAM,CAAC,KAAK,EAAE,CAAC"}
Run Code Online (Sandbox Code Playgroud)

./tsonfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "sourceMap": true
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}
Run Code Online (Sandbox Code Playgroud)

./.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/src/app.js",
            "stopOnEntry": true,
            "args": [],
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            },
            "externalConsole": false,
            "sourceMaps": true,
            "outDir": null
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

当我运行启动配置时,它在JS文件中断点,而不是TS文件.TS文件中的断点也为我提供了以下工具提示:

TS断点错误

我真的很喜欢我的TS和JS驻留在不同的目录中并使用Gulp来进行转换,但是想让这个简单的设置先工作.这只是VS Code中TS断点的一个例子,还是我做错了什么?

Ikh*_*yor -1

将 launch.json 添加到根文件夹,配置如下

{
    "version": "0.1.0",
    "configurations": [
        {
            "name": "Launch type",
            "type": "node",
            "program": "src/app.ts",
            "stopOnEntry": false,
            "sourceMaps": true,
            "outDir": "bin"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是参考链接https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations