You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When exporting certain kinds of types, the compiler can output code that ends up breaking up the type, leading to 'unexpected ' errors:
exporttypeMyType={foo: any}&{bar: any}
ends up producing the following code, which (understandably) raises an Unexpected "&" error.
exporttypeMyType={foo: any}const$$Index=$$createComponent(($$result,$$props,$$slots)=>{constAstro=$$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.
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:
ends up producing the following code, which (understandably) raises an
Unexpected "&"
error.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:
Additionally, I believe this issue is closely related to #997.
Link to Minimal Reproducible Example
https://idx.google.com/type-export-bug-2501330
The text was updated successfully, but these errors were encountered: