Skip to content

fix(compiler-sfc): support TypeScript 7 - #15085

Open
longlho wants to merge 1 commit into
vuejs:mainfrom
longlho:codex/compiler-sfc-typescript7
Open

fix(compiler-sfc): support TypeScript 7#15085
longlho wants to merge 1 commit into
vuejs:mainfrom
longlho:codex/compiler-sfc-typescript7

Conversation

@longlho

@longlho longlho commented Jul 14, 2026

Copy link
Copy Markdown

What

  • stop exposing the classic TypeScript API from the private registerTS declaration
  • keep loading TypeScript 5/6 directly, and fall back to @typescript/typescript6 when TypeScript 7 has no classic API
  • cover both loader paths and typecheck the built declaration with TypeScript 7

Why

TypeScript 7's root export only provides version metadata, while compiler-sfc still needs the classic compiler API for imported type resolution. The fallback follows the official TypeScript 7 migration guidance without installing a second compiler for users who do not need it.

Verification

  • pnpm test-unit --run
  • pnpm test-dts
  • pnpm check

Summary by CodeRabbit

  • New Features

    • Added compatibility for TypeScript 7 when using the Single-File Component compiler.
    • Automatically falls back to the TypeScript 6 compatibility package when needed.
    • TypeScript loading is now deferred until required, improving compatibility across supported setups.
  • Bug Fixes

    • Improved guidance for missing or unsupported TypeScript installations.
    • Preserved clearer handling of unexpected TypeScript loading errors.
  • Tests

    • Added coverage for standard TypeScript loading and TypeScript 7 fallback behavior.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 003b9bc8-fc38-4d49-ba52-f89722eb3fc7

📥 Commits

Reviewing files that changed from the base of the PR and between 9e03beb and 01d85de.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • package.json
  • packages-private/dts-test/compiler-sfc.typescript7.test-d.ts
  • packages-private/dts-test/package.json
  • packages-private/dts-test/tsconfig.typescript7.json
  • packages/compiler-sfc/src/script/resolveType.ts
  • packages/vue/__tests__/compilerSfc.spec.js
  • packages/vue/compiler-sfc/load-ts.js
  • packages/vue/compiler-sfc/register-ts.js
  • packages/vue/package.json

📝 Walkthrough

Walkthrough

The PR adds TypeScript module selection with a TypeScript 6 compatibility fallback, updates compiler registration and diagnostics, and introduces a TypeScript 7 declaration test configuration and test command.

Changes

TypeScript loading compatibility

Layer / File(s) Summary
Runtime TypeScript loader
packages/vue/compiler-sfc/load-ts.js, packages/vue/compiler-sfc/register-ts.js, packages/vue/package.json, packages/vue/__tests__/compilerSfc.spec.js
The compiler-SFC runtime loads compatible TypeScript implementations, treats @typescript/typescript6 as optional, and tests classic and TypeScript 7 loading paths.
Compiler TypeScript registration
packages/compiler-sfc/src/script/resolveType.ts
registerTS accepts an unknown loader result, casts it to the TypeScript API, and updates missing-module error messages.
TypeScript 7 declaration validation
packages-private/dts-test/package.json, packages-private/dts-test/tsconfig.typescript7.json, packages-private/dts-test/compiler-sfc.typescript7.test-d.ts, package.json
The dts-test package registers TypeScript 7, adds strict no-emit compiler settings and dependencies, and runs the new compilation check from the root script.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant register_ts as register-ts.js
  participant load_ts as load-ts.js
  participant node_require as require
  register_ts->>load_ts: loadTS(require)
  load_ts->>node_require: load("typescript")
  alt Compatible TypeScript
    node_require-->>load_ts: TypeScript module
  else TypeScript 7 or missing module
    load_ts->>node_require: load("`@typescript/typescript6`")
    node_require-->>load_ts: Compatibility module
  end
  load_ts-->>register_ts: Selected TypeScript module
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding TypeScript 7 support to compiler-sfc.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@longlho
longlho marked this pull request as ready for review July 14, 2026 20:58
@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 107 kB 40.3 kB 36.2 kB
vue.global.prod.js 165 kB 60.3 kB 53.7 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49 kB 19 kB 17.4 kB
createApp 57.1 kB 22.1 kB 20.2 kB
createSSRApp 61.6 kB 23.9 kB 21.8 kB
defineCustomElement 63.3 kB 24 kB 21.9 kB
overall 71.9 kB 27.5 kB 25.1 kB

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@15085
npm i https://pkg.pr.new/@vue/compiler-core@15085
yarn add https://pkg.pr.new/@vue/compiler-core@15085.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@15085
npm i https://pkg.pr.new/@vue/compiler-dom@15085
yarn add https://pkg.pr.new/@vue/compiler-dom@15085.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@15085
npm i https://pkg.pr.new/@vue/compiler-sfc@15085
yarn add https://pkg.pr.new/@vue/compiler-sfc@15085.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@15085
npm i https://pkg.pr.new/@vue/compiler-ssr@15085
yarn add https://pkg.pr.new/@vue/compiler-ssr@15085.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@15085
npm i https://pkg.pr.new/@vue/reactivity@15085
yarn add https://pkg.pr.new/@vue/reactivity@15085.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@15085
npm i https://pkg.pr.new/@vue/runtime-core@15085
yarn add https://pkg.pr.new/@vue/runtime-core@15085.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@15085
npm i https://pkg.pr.new/@vue/runtime-dom@15085
yarn add https://pkg.pr.new/@vue/runtime-dom@15085.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@15085
npm i https://pkg.pr.new/@vue/server-renderer@15085
yarn add https://pkg.pr.new/@vue/server-renderer@15085.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@15085
npm i https://pkg.pr.new/@vue/shared@15085
yarn add https://pkg.pr.new/@vue/shared@15085.tgz

vue

pnpm add https://pkg.pr.new/vue@15085
npm i https://pkg.pr.new/vue@15085
yarn add https://pkg.pr.new/vue@15085.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@15085
npm i https://pkg.pr.new/@vue/compat@15085
yarn add https://pkg.pr.new/@vue/compat@15085.tgz

commit: 01d85de

@edison1105

Copy link
Copy Markdown
Member

/ecosystem-ci run

@edison1105

Copy link
Copy Markdown
Member

Thanks for the contribution! Since TypeScript 7 does not currently expose the classic compiler APIs that compiler-sfc relies on, this still requires users to install @typescript/typescript6. I think it may be better to wait until TypeScript 7 provides a stable programmatic API before adding proper support.

@edison1105 edison1105 added the 🛑 on hold This PR can't be merged until other work is finished label Jul 15, 2026
@vue-bot

vue-bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
nuxt success success
pinia success success
vite-plugin-vue success success
quasar success success
vueuse success success
radix-vue success success
primevue success success
router success success
test-utils success success
vant success success
vitepress success success
vue-simple-compiler success success
vuetify success success
vue-macros success success
vue-i18n success success

@longlho

longlho commented Jul 15, 2026

Copy link
Copy Markdown
Author

yeah that's why I added it as optional peerDep. Looks like TS7.1 will come with an API and there's no timeline for it so far.

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

Labels

🛑 on hold This PR can't be merged until other work is finished scope: sfc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants