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

🐛 BUG: Incorrect parsing for exported types #1051

Closed
MrTipson opened this issue Nov 29, 2024 · 1 comment
Closed

🐛 BUG: Incorrect parsing for exported types #1051

MrTipson opened this issue Nov 29, 2024 · 1 comment
Labels
needs triage Issue needs to be triaged

Comments

@MrTipson
Copy link

What version of @astrojs/compiler are you using?

2.10.3

What package manager are you using?

pnpm

What operating system are you using?

Windows

Describe the Bug

When exporting certain kinds of types, the compiler can output code that ends up breaking up the type, leading to 'unexpected ' errors:

export type MyType = { foo: any
} & { bar: any }

ends up producing the following code, which (understandably) raises an Unexpected "&" error.

export type MyType = { foo: any
}
const $$Index = $$createComponent(($$result, $$props, $$slots) => {
const Astro = $$result.createAstro($$Astro, $$props, $$slots);
Astro.self = $$Index;
 & { bar: any }

I have confirmed this behavior for intersection, union and function types, but additional ones may exist.

While the issue can be worked around once you're aware of it, its:

  • not very easy to spot (since the typescript is correct in editor),
  • the resulting exceptions' stack traces are not useful and
  • the line number points at the wrong location in the file (or outside of it altogether).

Additionally, I believe this issue is closely related to #997.

Link to Minimal Reproducible Example

https://idx.google.com/type-export-bug-2501330

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 29, 2024
@Fryuni
Copy link
Member

Fryuni commented Dec 2, 2024

Both this and #997 seem to be duplicates of #554

@Princesseuh Princesseuh closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants