← 输入框|github.com|刷新
Skip to content

build: update to TypeScript 6 - #11588

Draft
edusperoni wants to merge 4 commits into
mainfrom
chore/typescript-6
Draft

edusperoni wants to merge 4 commits into
mainfrom
chore/typescript-6

Conversation

@edusperoni

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

The workspace builds with TypeScript 5.9. Under TypeScript 6 the tsconfigs fail on deprecated options (baseUrl, target: es5), several configs lose their implicit @types, and core fails to build because of a side-effect import that can't be resolved.

What is the new behavior?

Everything builds with TypeScript 6.0.3. Deprecations are fixed rather than silenced: there is no ignoreDeprecations anywhere, and the old "5.0" escape hatch is removed too. strict stays off (set explicitly, since TS 6 turns it on by default).

Dependencies (build: update to TypeScript 6.0)

  • typescript 6.0.3 at the root, in packages/webpack5, and in the test apps.
  • Nx 22.5.4 → 22.7.12. Nx 22.5 depends on @phenomnomnominal/tsquery 6.1, which rejects TS 6. 22.7 stays on major 22, so @nativescript/nx@22 still fits.
  • Angular dev tooling 21 → 22 and @analogjs/vite-plugin-angular 2.1.3 → 2.9.2. @angular/build@21 caps TS below 6.0. @nativescript/vite already lists ^22 as a peer.
  • typescript-eslint 8.72, ts-jest 29.4.15, typedoc 0.28.20, ts-patch 4 (the first versions that accept TS 6).
  • Applied the @nx/vitest 22.6 reportsDirectory migration.
  • vite: require.resolve of its own HMR client files now uses relative paths. This fixes the stricter @nx/enforce-module-boundaries check in Nx 22.7. The exports map is identity, and I checked that both forms resolve to the same file in dist.
  • Removed 15 stale extraneous entries from package-lock.json (apps/*, dist/*, packages/*). They pinned Angular 21 and blocked resolution.

tsconfigs (build: migrate tsconfigs off options deprecated in TypeScript 6)

  • baseUrl removed everywhere. paths entries are now ./-relative to the tsconfig that declares them.
  • target: es5 in the tools configs is replaced by the workspace ES2020 target.
  • strict: false is set explicitly, and types is listed explicitly where configs relied on implicit @types (webpack5 jest/node, devtools node).
  • typedoc config: it now inherits module/lib from the base config. On 5.9 it stopped at a config error (TS5095); typedoc --emit none now reports 0 errors.

Declarations (fix(core): declarations compatible with TypeScript 6)

  • module Foo {} → namespace Foo {} in hand-written declarations (global-types.d.ts, interop.d.ts, org.nativescript.widgets.d.ts, android-declarations.d.ts). TS 6 makes this an error. In .d.ts files it only shows up with skipLibCheck: false, so consumers who check lib files would hit it.
  • New debugger/webinspector-network.d.ts. The module only has .ios/.android files, so import './debugger/webinspector-network' failed under TS 6's default noUncheckedSideEffectImports.
  • global-types.d.ts used import('data/observable'), which only resolved through baseUrl. It is now relative.

NativeClass (fix(webpack,vite): strip the "use strict" prologue…)

  • TS 6 always emits "use strict" when transpiling a snippet that has no imports or exports. The NativeClass ES5 downlevel splices that output into the host module. All five transpile sites now strip the prologue. Output is otherwise byte-identical to 5.9. (moduleDetection: force was rejected because it appends export {}, which is invalid where the webpack transformer splices into blocks.)

Verification

  • nx run-many -t build -p core,webpack5,vite: passes. The core dist still has __extends NativeClass output and no stray "use strict".
  • tsc --noEmit across all 17 tsconfigs: same as the TS 5.9 baseline on main or better. The remaining errors exist on main too (spec configs, apps without installed deps).
  • Tests: core 565 passed. webpack5 has 16 failures and vite has 5. Both match main exactly: the webpack5 snapshots hard-code /Users/nstudio/... paths, and vite's typescript-optional.spec passes when run alone.
  • Lint: identical to main (the same 3 pre-existing vite errors).

Known follow-ups (not in this PR)

  • Generated Android typings: androidx-*.d.ts and android-platform-*.d.ts in types-android/types-minimal still use module org { … }, about 85k occurrences. This is the same TS 6 error, visible to consumers with skipLibCheck: false. It needs a mechanical conversion, ideally fixed in the typings generator, as a separate change.
  • TypeScript 7: the NativeClass transformers still call transpileModule with target: ES5. TS 6 still supports this (it raises a deprecation diagnostic that these call sites don't report). TS 7 removes ES5 output, so that downlevel will need another approach before 7.
  • @nx/eslint 22.x and the nativescript CLI ship their own nested TypeScript (5.9 / 5.7). That copy doesn't affect builds here.

- typescript 6.0.3 across the workspace and test apps
- Nx 22.5.4 -> 22.7.12 (22.5 pins @phenomnomnominal/tsquery 6.1, which rejects TS 6)
- Angular dev tooling 21 -> 22, @analogjs/vite-plugin-angular 2.9.2 (first lines that accept TS 6)
- typescript-eslint 8.72, ts-jest 29.4.15, typedoc 0.28.20, ts-patch 4
- apply the @nx/vitest 22.6 reportsDirectory migration
- vite: resolve own hmr client files relatively (stricter enforce-module-boundaries in Nx 22.7)
- drop stale extraneous entries from package-lock.json
- remove baseUrl; paths entries are now relative to the declaring tsconfig
- replace target es5 (tools) with the workspace ES2020 target
- drop the ignoreDeprecations "5.0" escape hatch
- set strict: false explicitly (TS 6 defaults it to true)
- list types explicitly where configs relied on implicit @types inclusion (TS 6 defaults types to [])
- typedoc config: inherit module/lib from the base config so core type-checks under it
- apps/ui: drop the unused tns-core-modules/* path mapping
- use the namespace keyword instead of module for namespace declarations (an error in TS 6)
- add webinspector-network.d.ts so the side-effect import in inspector_modules resolves (noUncheckedSideEffectImports is on by default in TS 6)
- global-types.d.ts: import data/observable relatively instead of through baseUrl
…S5 snippets

TypeScript 6 always emits "use strict" for transpiled snippets that have no
imports/exports. The NativeClass downlevel splices that output into the host
module, so the prologue would land mid-file (or become the file prologue).
@nx-cloud

nx-cloud Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 17063bd

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 29s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-26 00:09:32 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11588
npm i https://pkg.pr.new/@nativescript/vite@11588
npm i https://pkg.pr.new/@nativescript/webpack@11588

commit: 17063bd

This branch has not been deployed

No deployments
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