compiler
compiler copied to clipboard
Props Type parsing fails when using union/ intersection types without brackets
What version of astro are you using?
2.1.2
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
Mac
What browser are you using?
Chrome
Describe the Bug
When using union or intersection type definitions on Props the transformation fails.
For example:
---
export type Props = {
specs: {
name: string;
};
} & {
additional: string;
}
const { specs, additional } = Astro.props as Props;
Results in Unexpected "&"
Quick Fix:
---
export type Props = ({
specs: {
name: string;
};
} & {
additional: string;
})
const { specs, additional } = Astro.props as Props;
Semantically both examples should be the same.
Link to Minimal Reproducible Example
https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal?file=src/components/Test.astro
Participation
- [ ] I am willing to submit a pull request for this issue.
The repro link doesn't look right, but here's a repro based on the description. This seems to be a compiler issue.
Duplicate of https://github.com/withastro/compiler/issues/554