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

Build Error with Props syntax using type and pick #951

Closed
1 task
silveltman opened this issue Jan 23, 2024 · 2 comments
Closed
1 task

Build Error with Props syntax using type and pick #951

silveltman opened this issue Jan 23, 2024 · 2 comments

Comments

@silveltman
Copy link

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.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 23, 2024
@MoustaphaDev
Copy link
Member

MoustaphaDev commented Jan 23, 2024

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

@MoustaphaDev MoustaphaDev added needs response and removed needs triage Issue needs to be triaged labels Jan 23, 2024
@MoustaphaDev MoustaphaDev transferred this issue from withastro/astro Jan 24, 2024
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 24, 2024
@MoustaphaDev MoustaphaDev removed the needs triage Issue needs to be triaged label Jan 24, 2024
@MoustaphaDev
Copy link
Member

MoustaphaDev commented Feb 12, 2024

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!

@MoustaphaDev MoustaphaDev closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants