Skip to content
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

Expose Svelte AST node types from svelte/compiler to public #12292

Closed
xeho91 opened this issue Jul 4, 2024 · 5 comments · Fixed by #12968
Closed

Expose Svelte AST node types from svelte/compiler to public #12292

xeho91 opened this issue Jul 4, 2024 · 5 comments · Fixed by #12968
Assignees
Milestone

Comments

@xeho91
Copy link
Contributor

xeho91 commented Jul 4, 2024

Describe the problem

As per thread on Discord.

I was working on addon for Storybook - @storybook/addon-svelte-csf. It uses svelte/compiler to extract Svelte AST nodes and analyss them for further code transformation.

Then I upgraded Svelte version. And I have noticed that since this release svelte@5.0.0-next.165 AST nodes from svelte/compiler are no longer exposed to public.

Such as:

  • Component (AST version)
  • Root
  • SnippetBlock
  • SvelteNode
  • ... etc.

Possibly related PR: Rich-Harris/dts-buddy#82

Describe the proposed solution

I would like to be able to access those Svelte AST nodes, so I can have a better typings experience on those AST data structures.

Importance

would make my life easier

@xeho91 xeho91 changed the title Expose Svelte AST node types from svelte/compiler Expose Svelte AST node types from svelte/compiler to public Jul 4, 2024
@benmccann benmccann added this to the 5.0 milestone Jul 4, 2024
@benmccann
Copy link
Member

We also need need this to get SvelteKit passing against the ecosystem CI since enhanced-img uses things like TemplateNode, BaseDirective, Attribute, and SpreadAttribute

https://github.com/sveltejs/kit/blob/43544107269013e8b5160d268da25f1e003b6f6f/packages/enhanced-img/src/preprocessor.js#L44
https://github.com/sveltejs/kit/blob/43544107269013e8b5160d268da25f1e003b6f6f/packages/enhanced-img/src/preprocessor.js#L216

@dummdidumm
Copy link
Member

dummdidumm commented Jul 6, 2024

If we expose them again I'd like us to make sure somehow to not expose the internal properties of the AST nodes (for example metadata)

@huntabyte
Copy link
Member

Hey @dummdidumm, is it just the metadata that needs to be omitted from the public interfaces or is there more? Not having these types is blocking us on a couple of things, so we are willing to attempt a PR with some guidance.

I imagine the desire is to incorporate this into the build script rather than just exporting with Omit right?

@dummdidumm
Copy link
Member

Yeah metadata is basically all that needs to be removed (and if there's a parent property, then that, too).
I have no opinion at this time how it should be accomplished, as long as it's low maintenance, stable and relatively straightforward

@vnphanquang
Copy link

@huntabyte there was some additional discussion in the original Discord thread FYI: https://discord.com/channels/457912077277855764/1258093339232702556

@dummdidumm dummdidumm self-assigned this Aug 21, 2024
dummdidumm added a commit to Rich-Harris/dts-buddy that referenced this issue Aug 21, 2024
... using `@internal` JSDoc tags, if the `stripInternal` tsconfig compiler option is enabled. This means types annotated with `@internal` will be stripped both from .js/ts files going through the TS program aswell as d.ts files going through our logic

part of sveltejs/svelte#12292
dummdidumm added a commit that referenced this issue Aug 22, 2024
Also hides the legacy AST types from the output

closes #12292
Rich-Harris pushed a commit to Rich-Harris/dts-buddy that referenced this issue Aug 22, 2024
* feat: support stripping internal types

... using `@internal` JSDoc tags, if the `stripInternal` tsconfig compiler option is enabled. This means types annotated with `@internal` will be stripped both from .js/ts files going through the TS program aswell as d.ts files going through our logic

part of sveltejs/svelte#12292

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