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

Props Type parsing fails when using union/ intersection types without brackets #749

Closed
1 task
space-otter opened this issue Mar 12, 2023 · 2 comments
Closed
1 task
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@space-otter
Copy link
Contributor

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.
@bluwy
Copy link
Member

bluwy commented Mar 13, 2023

The repro link doesn't look right, but here's a repro based on the description. This seems to be a compiler issue.

@bluwy bluwy transferred this issue from withastro/astro Mar 13, 2023
@natemoo-re natemoo-re self-assigned this Mar 23, 2023
@natemoo-re natemoo-re added the - P3: minor bug An edge case that only affects very specific usage (priority) label Jun 27, 2023
@Princesseuh
Copy link
Member

Duplicate of #554

@Princesseuh Princesseuh marked this as a duplicate of #554 Jul 23, 2024
@Princesseuh Princesseuh closed this as not planned Won't fix, can't repro, duplicate, stale Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

4 participants