fix: split types per entrypoint for alias installs#17650
fix: split types per entrypoint for alias installs#17650RazinShafayet2007 wants to merge 2 commits intosveltejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 447a77c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
d1ad90c to
4bb3741
Compare
|
Thank you. The reason we do things this way is because not all TypeScript configurations support subpath resolution; we found that the easiest way to make it work everywhere was with Additionally, why does every entrypoint re-export from |
|
Thanks. That makes sense. However, I don’t see a clean compatibility‑preserving fix for arbitrary alias names without relying on modern |
Isn't it sufficient to import them from the same place? Why do they also need to be exported? |
You’re right that a single canonical import source is enough for internal references. I added per-entrypoint |
Fixes #17520
This PR fixes TypeScript type resolution when Svelte is installed under a package alias. Previously, Svelte relied on a single ambient
types/index.d.tswith hard‑coded module names likesvelte/compiler. When the package is aliased, those ambient declarations don’t match the installed specifiers (e.g.svelte5/compiler), so TypeScript reports “is not a module.” This also breaks tooling liketsup,tsdown, and other DTS bundlers.To fix this, types are now aligned with the export map by generating per‑entrypoint
.d.tsfiles (e.g.types/compiler.d.ts,types/store.d.ts, etc.) and wiringexports.typesto those files. This makes TypeScript resolve types via the entrypoint file path, which is agnostic to the package name. Core type identities are centralized intypes/shared.d.ts, and global/ambient declarations are isolated intypes/ambient.d.tsto avoid cross‑module conflicts.With this change, aliased installs resolve types correctly, subpath imports no longer error, and downstream tooling can bundle or analyze Svelte types reliably. Non‑aliased installs remain unchanged.
Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.packages/svelte/src, add a changeset (npx changeset).Tests and linting
pnpm testand lint the project withpnpm lint