Build Error with Props syntax using type and pick
silveltman opened this issue · 2 comments
Astro Info
Astro v4.2.1
Node v18.17.1
System macOS (arm64)
Package Manager yarn
Output static
Adapter none
Integrations @astrojs/svelte
@astrojs/sitemap
astro-robots-txt
bookshop
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I have the following component:
---
import type { Props as SectionProps } from '../../elements/section/Section.astro'
type Props = Pick<
SectionProps,
'level' | 'layout' | 'tagline' | 'heading' | 'text'
>
---
and get this error:
Expected ">" but found "$$ContactSection"
28 | export type Props = Pick<
29 |
30 | const $$ContactSection = $$createComponent(async ($$result, $$props, $$slots) => {
| ^
31 | const Astro = $$result.createAstro($$Astro, $$props, $$slots);
32 | Astro.self = $$ContactSection;
Expected ">" but found "$$ContactSection"
What's the expected result?
I expect it to work. Like this it does work:
---
import type { Props as SectionProps } from '../../elements/section/Section.astro'
import Section from '../../elements/section/Section.astro'
interface Props
extends Pick<
SectionProps,
'level' | 'tagline' | 'heading' | 'text' | 'image'
> {}
also, on a single line it works:
import type { Props as SectionProps } from '../../elements/section/Section.astro'
import Section from '../../elements/section/Section.astro'
type Props = Pick<SectionProps, 'level' | 'layout'>
I've unfortunately not been able to reproduce, but thought it might still be worth sharing.
I did get the error earlier locally, but not anymore. I do however get the error in a build on CloudCannon. Might it be due to some build environments?
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-m7etjv?file=src%2Fcomponents%2FSection.astro
Participation
- I am willing to submit a pull request for this issue.
Were you exporting the Props
type in your component locally? If yes, we are tracking an issue related to that in #554
Let me know if that's the case @silveltman
I'm going to close this for now as I couldn't reproduce with your reproduction and I noticed that when I export the type, the error I get seems identical to yours: https://stackblitz.com/edit/github-m7etjv-t573xo?file=src%2Fcomponents%2FSection.astro
That bug is tracked in #554
Feel free to reopen if you can reproduce @silveltman!