Skip to content

fix: avoid TypeScript 7 config diagnostics - #305

Open
Changdw wants to merge 1 commit into
cocos:v4.0.0from
Changdw:codex/fix-engine-ts7-vscode
Open

fix: avoid TypeScript 7 config diagnostics#305
Changdw wants to merge 1 commit into
cocos:v4.0.0from
Changdw:codex/fix-engine-ts7-vscode

Conversation

@Changdw

@Changdw Changdw commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Re: #

Changelog

  • Fix TypeScript configuration errors shown when opening the engine source code in VS Code with TS7/tsgo globally enabled.
  • Keep the engine workspace using its bundled TypeScript 4.9.5.
  • Remove baseUrl and downlevelIteration, and use explicit relative paths mappings to preserve the existing module resolution behavior.
  • This change does not include a full TS7 compatibility upgrade for the engine source code.

Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.

The full type check passes with the engine's bundled TypeScript 4.9.5.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
    • This change only affects the TypeScript development tooling used by VS Code.
    • TS7/tsgo may remain enabled globally, while the engine workspace uses its bundled TypeScript 4.9.5.
    • Runtime behavior, build output, and user projects are not affected.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@Changdw

Changdw commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

修改说明

解决全局启用 TS7/tsgo 后,打开 Cocos 引擎源码出现 TypeScript 配置报错的问题。

主要修改

  • 引擎工作区关闭 typescript.experimental.useTsgo,继续使用引擎自带 TS4.9.5。
  • 删除 TS7 已不支持的 baseUrl、downlevelIteration。
  • 使用显式相对 paths,保留原有模块解析行为。
  • 同步调整 cc.decorator 和 @cocos/engine/* 映射。

@Changdw

Changdw commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author
wecom-temp-71766-0f74db4508de6aedec33ab19fd35397a image image image
  • Cocos Engine v4.0.0 和 v3.8.8 当前使用的 TypeScript 版本均为 v4.9.5。
  • VS Code v1.107.1 内置的 TypeScript 版本为 v5.9.3。
  • 在 Cocos Engine 开发场景中,VS Code 使用 TypeScript 提供静态类型检查、语法诊断、代码补全和跳转等编辑器能力。
    如需使用 TypeScript 7 进行静态检查,可以在 VS Code 中安装 “TypeScript 7” 扩展。
  • 安装后可按 Ctrl + Shift + P,执行 TypeScript Native Preview: Show Output,并在“问题”面板中查看诊断结果。
  • TypeScript 在这里主要用于编辑器静态检查,并不参与 Creator 用户脚本的开发期增量编译或构建期编译。Creator 实际使用 Babel、QuickPack、Rollup 等工具处理用户脚本。
  • 如果后续需要真正支持 TS7 的新语法,还需要评估并升级 Babel、Rollup 等编译和构建工具,不能只升级 VS Code 的 TypeScript 检查器。
  • TS7 主要采用基于 Go 重写的 tsgo。根据官方早期测试数据,其类型检查速度在部分项目中可提升约 10 倍。
  • 当前修改以保持引擎源码无诊断错误为目标,因此在引擎工作区暂时设置了 "typescript.experimental.useTsgo": false,继续使用引擎自带的 TypeScript 4.9.5;其他工作区仍可使用 TS7。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant