Skip to content

feat: typescript 6.0 support#2985

Merged
jasonlyu123 merged 21 commits intosveltejs:masterfrom
jasonlyu123:ts-6.0
May 5, 2026
Merged

feat: typescript 6.0 support#2985
jasonlyu123 merged 21 commits intosveltejs:masterfrom
jasonlyu123:ts-6.0

Conversation

@jasonlyu123
Copy link
Copy Markdown
Member

@jasonlyu123 jasonlyu123 commented Mar 24, 2026

User Migration Guide

TypeScript is now a peerDependency

For users manually installing the language server, this includes VSCode users using the "svelte.language-server.ls-path" config. You also need to install TypeScript for the language server if it's not automatically installed.

TypeScript 6

See https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/#breaking-changes-and-deprecations-in-typescript-6.0

Most notably:

PR details

This changes our moduleResolution config to node16 or bundler. It's mostly just some config changes. Only problem is estree-walker. The types for estree-walker v2 can't be resolved under node16, but v3 is ESM only, so copying the type for now.

As for bundling TypeScript 6, this is definitely a breaking change for the extension. Is there any other breaking change we want to ship with this? And what about language-server? Is this considered a breaking change if both are allowed? Actually don't know if || works in dependencies. This will also move typescript to peerDependency, so it'll be a breaking change.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: 0f1ce0b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
svelte-language-server Minor
svelte-check Patch
svelte2tsx Patch
typescript-svelte-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/language-server/tsconfig.json Outdated
Comment thread packages/svelte2tsx/test/tsconfig.json
Comment thread packages/language-server/package.json Outdated
"svelte": "^4.2.19",
"svelte2tsx": "workspace:~",
"typescript": "^5.9.2",
"typescript": "^5.9.2 || ^6.0.2",
Copy link
Copy Markdown
Member

@teemingc teemingc Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the || syntax works here. Is the intention to provide support for both? It might be better to specify this as a peerDep instead 🤔 though I'm not sure how that works with VS Code extensions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's meant to support both. I tested by installing a git repository, and it seems to be working as I intended: By default, it installs 6.0 and can be manually overridden to be 5.9. I think we can also move it to peerDep and mark it a breaking change?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

peer dep sounds good, though we gotta do language-server package as a minor then

@jasonlyu123
Copy link
Copy Markdown
Member Author

jasonlyu123 commented Mar 25, 2026

About the failed test. I narrowed down the problem to svelteHTML.mapElementTag. For some reason, TypeScript try to create a union for every property of HTMLElement to its derived types. For example, HTMLElement.hidden and HTMLDivElement.hidden. This adds around 10ms (about 30%) on my machine for each iteration of the performance test. But it only runs once during the type-checker's lifetime, i.e. every keystroke. 10ms every keystroke is not small, but it's not really that noticeable. I'll still try to create an issue in TypeScript, but I don't think this is a major blocker.

Edit: Just noticed TypeScript team has updated the README with a merge criteria for the old codebase. Guess we have missed the beta/RC phase to get this fixed 😅.

@jasonlyu123
Copy link
Copy Markdown
Member Author

Draft until the next release. Wanted to release the current patches before we update the extension to use TypeScript 6.

@jasonlyu123 jasonlyu123 marked this pull request as ready for review March 31, 2026 02:14
teemingc added a commit to sveltejs/kit that referenced this pull request Apr 1, 2026
closes #15372

This PR extends the SvelteKit peerDep range to include TS 6.0. It also
upgrades our apps/packages using TS purely as a devDependency to use 6.0
(this excludes `kit` because we use TS to generate public types and that
can be a breaking change. `package` is also excluded because it can't
support TS6 until svelte2tsx does).

### TODOs

- [x] update `svelte-check`
sveltejs/language-tools#2988

Required for `@sveltejs/package` if we want to support TS6 in the
future:
- [ ] update `svelte2tsx`
sveltejs/language-tools#2985
- [ ] update `svelte-preprocess`
sveltejs/svelte-preprocess#675

Required for SvelteKit 3 when we switch over to TS6 completely
- [x] update `@sveltejs/eslint-config`
sveltejs/eslint-config#67
- [ ] update `dts-buddy` sveltejs/dts-buddy#123

---

### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:
- [ ] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs
- [ ] This message body should clearly illustrate what problems it
solves.
- [ ] Ideally, include a test that fails without this PR but passes with
it.

### Tests
- [ ] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets
- [ ] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.

### Edits

- [ ] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"strict": false,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one day we will mark this strict and fight all the errors that come from it 😆

@dummdidumm
Copy link
Copy Markdown
Member

I narrowed down the problem to svelteHTML.mapElementTag.

Mhhhm can we adjust the type in a way that it's not that costly anymore? Feels kinda bad that it will regress this much per keystroke.

@jasonlyu123
Copy link
Copy Markdown
Member Author

Mhhhm can we adjust the type in a way that it's not that costly anymore

Maybe we could still try our luck to open an issue. Not entirely sure why it does that. document.createElement doesn't, on the other hand. And it also doesn't appear in typescript-go, although the hot path has a corresponding code in typescript-go. I tried debugging with the debugger, but the same svelteHTML.mapElementTag doesn't trigger the problem during type-check.

@jasonlyu123
Copy link
Copy Markdown
Member Author

Pretty weird that the performance problem also happened in typescript go on another PC. I created
microsoft/TypeScript#63347. Hope at least it can be improved in typescript go.

@jasonlyu123
Copy link
Copy Markdown
Member Author

Hmm. It actually isn't caused by runtime code changes in TypeScript 6, but the DOM definition update. Might be an existing problem that gets triggered by the DOM update.

TypeScript 6 is also noticeably faster in some areas. Besides the performance test, our language server test is reliably faster with TypeScript 6. I also just noticed that the benchmark in the performance test is faster, so part of the reason it failed is that the target time has also decreased.

shouldn't matter in most cases but still restore the original logic
@jasonlyu123
Copy link
Copy Markdown
Member Author

jasonlyu123 commented May 1, 2026

I'll merge this next week if there's no objection. The upstream issue for the mapElement problem mentioned is closed as "Not a defect", so it's probably not possible to fix the root cause of the problem in TypeScript 6.

@jasonlyu123 jasonlyu123 merged commit 29e2894 into sveltejs:master May 5, 2026
3 checks passed
@jasonlyu123 jasonlyu123 deleted the ts-6.0 branch May 5, 2026 01:00
@github-actions github-actions Bot mentioned this pull request May 5, 2026
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.

3 participants