属性 vs 代码 launch.json 中不允许使用 outFiles
Property outFiles is not allowed in vs code's launch.json
我正在尝试在 vs code 中调试打字稿。据我研究,您需要在 th launch.config 中设置输出文件 属性 以便 vs 代码映射您在已编译的 .js 文件的 TypeScript 文件中设置的断点,如指定的那样 here.
当我尝试设置我的时,出现此错误:
我在 google 中没有发现任何关于此错误的信息,因为 typescript 调试器需要此设置才能工作,如 vs code documentation.
中所示
在此先感谢您的帮助。
编辑:
launch.json:
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"preLaunchTask": "tsc",
"sourceMaps": true
}
]
tsconfig:
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"strict": true, /* Enable all strict type-checking options. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
"inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"outDir": "src/ts-built",
"rootDir": "src"
}
}
您不能将 "outFiles" : true
用于 chrome 调试配置
如果您要调试打字稿代码,则需要确保已将 ts 编译器设置为生成源映射。
确保您的 tsconfig
文件中有这两个设置。
//TSCONFIG SETTINGS
"inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */,
"inlineSources": true /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */,
如果您的 tsconfig
中已经有 "sourceMap": true,
,如果您想使用 "inlineSourceMap": true
NOT FROM LAUNCH.JSON!
,则需要将其删除
这些设置将为您的代码生成内联源映射。
最后你的 launch.config 应该看起来像这样
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/wwwroot",
"sourceMaps": true // this is is the important setting.
}
我正在尝试在 vs code 中调试打字稿。据我研究,您需要在 th launch.config 中设置输出文件 属性 以便 vs 代码映射您在已编译的 .js 文件的 TypeScript 文件中设置的断点,如指定的那样 here.
当我尝试设置我的时,出现此错误:
我在 google 中没有发现任何关于此错误的信息,因为 typescript 调试器需要此设置才能工作,如 vs code documentation.
中所示在此先感谢您的帮助。
编辑:
launch.json:
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"preLaunchTask": "tsc",
"sourceMaps": true
}
]
tsconfig:
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"strict": true, /* Enable all strict type-checking options. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
"inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"outDir": "src/ts-built",
"rootDir": "src"
}
}
您不能将 "outFiles" : true
用于 chrome 调试配置
如果您要调试打字稿代码,则需要确保已将 ts 编译器设置为生成源映射。
确保您的 tsconfig
文件中有这两个设置。
//TSCONFIG SETTINGS
"inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */,
"inlineSources": true /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */,
如果您的 tsconfig
中已经有 "sourceMap": true,
,如果您想使用 "inlineSourceMap": true
NOT FROM LAUNCH.JSON!
这些设置将为您的代码生成内联源映射。
最后你的 launch.config 应该看起来像这样
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/wwwroot",
"sourceMaps": true // this is is the important setting.
}