Skip to content

Commit 0b24518

Browse files
committed
fix(build): 修复 TypeScript 配置以兼容 tsgo 编译器
scripts/node 项目中将 module 设置为 Preserve,moduleResolution 设置为 Bundler, 以解决 tsgo 基于新版本 TypeScript 时 node 模块解析问题。 json-diff-tool 项目中添加 types: ["node"] 配置,显式声明 Node 全局类型, 避免 process、console、NodeJS 和 node: 内建模块在快检阶段丢失类型。
1 parent f7398ec commit 0b24518

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

projects/clis/json-diff-tool/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"compilerOptions": {
3+
// `tsgo` 不会像旧的 `tsc` 组合那样总是隐式带上 Node 全局类型;
4+
// 显式声明可避免 `process`、`console`、`NodeJS` 和 `node:` 内建模块在快检阶段丢失类型。
5+
"types": ["node"],
36
"target": "ES2020",
47
"module": "commonjs",
58
"lib": ["ES2020"],

scripts/node/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"compilerOptions": {
33
"target": "ES2022",
4-
"module": "CommonJS",
5-
"moduleResolution": "node",
4+
// `tsgo` 基于新一代 TypeScript 时会把 `node` 解析成已移除的 `node10`;
5+
// 这里改为 `bundler` + `preserve`,既能兼容 ESM 依赖(如 `inquirer`),也能保留仅做类型检查时需要的解析语义。
6+
"module": "Preserve",
7+
"moduleResolution": "Bundler",
68
"esModuleInterop": true,
79
"forceConsistentCasingInFileNames": true,
810
"strict": true,

0 commit comments

Comments
 (0)