node.js - 调试会话期间的打字稿未定义常量
问题描述
我有以下带有 Typescript项目的 Node.js,它运行得非常好。但是,在调试会话期间,我注意到从另一个 Typescript 文件中导出的常量始终是undefined
:
我有点怀疑这是由于生成的源映射names
中的空数组:
{
"version": 3,
"file": "main.js",
"sourceRoot": "",
"sources": [
"../src/main.ts"
],
"names": [], // <---- empty
"mappings": ...details omitted...
}
有没有办法从Typescript编译器或其他解决方案来解决这个调试问题?以下是我的tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"target": "es2017",
"noImplicitAny": true,
"moduleResolution": "node",
"importHelpers": true,
"sourceMap": true,
"allowJs": true,
"outDir": "dist",
"baseUrl": ".",
"typeRoots": [
"./node_modules/@types"
],
"types": [
"node"
],
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
]
}
我正在使用 Typescript 3.7.5。
该项目只是通过 Webstorm 的 Node runner 运行:
旁注:当我调试一个运行的 Angular 应用程序时,这个问题没有发生ng serve
。不确定ng serve
与标准有何不同tsc
。
解决方案
推荐阅读
- suitescript2.0 - 源国家列表到 NetSuite 套件选择字段
- python - 为什么我的python库的一个旧版本的包是用pip -e自行安装的?
- android - Flutter:无法使用 json 在列表视图中获取产品
- java - 无法使用返回 false 的 equalsIgnoreCase 验证字符串
- javascript - 如何仅使用特定元素对数组进行排序?
- database - 在 MariaDb 10.6 中更改 NVARCHAR 列的默认排序规则
- concourse - How disable a time resource in Concourse? No Operation?
- python - Using python to solve FIFO inventory problem
- android - Sticky header outside of recyclerview
- css - css tooltip goes offscreen (only on mobile)