-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate type declarations with dts-buddy
#8702
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool!!
btw, one thing I noticed is that if you build twice on the sites
branch then the types generation fails. might be worth taking a look at while you're in this section of the code
That's cuz the sites' script expects multiple files it can bundle using roll-up plugin dts. This PR renders the entire logic useless. We'll need to rewrite the script to account for the declare module stuff now, although it should be faaaar more easier now |
ah yeah, that makes sense — had to make a similar change on the kit repo https://github.com/sveltejs/kit/pull/9992/files#diff-a139886ac75fed1841162f1a5ba8fdfa4fca12f24428f065a9f978e41840ba82 |
There's one thing I'd like to add back (manually?) somehow or at least make aware of which is the |
To clarify, it looks like it's actually |
Those types should probably be part of the |
Ok, I've added I think this PR is probably ready to go, unless there's anything else you can see? |
Do those have to be majors? |
Lint is failing btw |
Some folks do use |
Yeah, because they'd need to drop support for Svelte 3 |
They shouldn't be! And yes, they'll lose typing (in fact I think using those things will cause typechecking to fail, which is good)
Dammit I broke something in dts-buddy. Investigating |
v-p-s is likely going to do a major for vite5 / drop node16 in September or early October |
Should be fixed now |
Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com>
learn.svelte.dev also will boot up so much faster now!!! 🔥 Does this release include the dequel change in ARIAQuery yet? |
No. That change has been merged, but not released. They said hopefully later this week they can cut a release |
Damn!! So it can down even more 🔥 |
* chore: playground (#8648) * initialize playground * pnpm up * tidy up git ignore * remove fluff * format * rm readme * fix jsconfig error * add skip-worktree instructions * reload hack * simplify * use rollup * ughh * add flag for SSR * ... * simplify further * configure launch.json * add debugger info to readme * remove vm modules flag * use replaceAll instead of replace * tidy up * fix: make it run * add watch to launch config * Generate type declarations with `dts-buddy` (#8702) * use dts-buddy * remove debug output * remove existing type generation script * fix package.json * update gitignore * bump dts-buddy * remove unused action entry point * add svelte/compiler and svelte/types/compiler/preprocess modules * bump dts-buddy * annoying * changeset * bump dts-buddy * get rid of .d.ts files * another one * Update packages/svelte/package.json Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> --------- Co-authored-by: Rich Harris <git@rich-harris.dev> Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> * fix: export ComponentType (#8694) * fix: export ComponentType * ughh * changeset * fix: derived types (#8700) * fix: derived store types * changeset * Version Packages (next) (#8709) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * update type generation script * remove unused stuff * fix: changeset publish script isn't called release anymore (#8711) * chore: remove prepare script (#8713) * chore: fix release workflow (#8716) * More readable, Fix $$_attributes * Fix types (#8727) * put comment in right place * bump dts-buddy --------- Co-authored-by: Rich Harris <git@rich-harris.dev> * build types * add svelte/compiler types * remove prepare script * fix * typo * squelch errors * Add svelte and kit to twoslash's types field * squelch more stuff * Add errors to account for new types * Remove deps * formatting tweak * fix linting, maybe * the hell * gah * Fix types a bit * bump dts-buddy * pnpm generate in dev mode * Cache again * reduce index * bump dts-buddy * remove comment --------- Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Co-authored-by: Rich Harris <git@rich-harris.dev> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Dominik G <dominik.goepel@gmx.de> Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Puru Vijay <devpuruvj@gmail.com>
This provides us with better type declarations and a smaller package. On the
version-4
branch, thetypes
directory takes 300kb (or 1.1MB on disk, because it's 264 separate files). In this PR, it takes 23kb (25kb on disk) with two files.All the types are put into a single bundle, and treeshaken (so we don't ship internal types that aren't referenced by public APIs).
As well as the size benefits, this provides a much better experience for Svelte users. This is what happens today:
dts-buddy-before.mov
Notice a few things:
svelte/internal.js
.svelte
is available in the auto-import menu (it's confusing that they're both there), but you have to actively select itonMount
takes you to the .d.ts file, rather than the implementation. (Even though the implementation isn't all that self-explanatory in the case ofonMount
, developers overwhelmingly prefer this behaviour.)in:fade
doesn't trigger an auto-import forsvelte/transition
— VSCode simply can't find it. It can find a horrendous list of internal junk likefix_and_destroy_block
fromsvelte/types/runtime/internal/each
svelte/transition.js
, most likely because of my editor configuration. This will not resolve correctlyfade
but, again, it takes you to the type declaration. This time, it is useful to go straight to the implementation, to understand how you'd build your own custom transitionWith this PR, things look very different:
dts-buddy-after.mov
Because it uses
declare module
, nothing relies on the app developer having the right TypeScript/editor configuration (moduleResolution
, file extension preferences etc) to get the right imports, and there are no false positives — just the public API.