compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Build fails when exporting a type using MarkdownLayoutProps

Open phelipetls opened this issue 3 years ago • 10 comments

What version of astro are you using?

1.6.6

Are you using an SSR adapter? If so, which one?

No

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

Exporting a type using MarkdownLayoutProps causes the following error.

[plugin:astro:build] Expected ">" but found "const"

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-yaiimj?file=src/pages/index.astro

Participation

  • [ ] I am willing to submit a pull request for this issue.

phelipetls avatar Nov 13 '22 01:11 phelipetls

The correct usage of this feature is to not export the type Edit: I was wrong actually

MoustaphaDev avatar Nov 13 '22 10:11 MoustaphaDev

Got it. To clarify I exported it to stop the @typescript-eslint/no-unused-vars rule from complaining, what should I do instead? Should I just configure the rule to not apply for this type in astro files?

phelipetls avatar Nov 13 '22 11:11 phelipetls

Maybe you can use a // @ts-ignore ?

MoustaphaDev avatar Nov 13 '22 15:11 MoustaphaDev

Yes, suppressing the error is what I'm doing now, with // eslint-disable-next-line @typescript-eslint/no-unused-vars, but I was wondering if there was a better way to handle this.

I opened the issue because the error message seemed to me like a weird one, thought it might be a bug, but feel free to close if this is expected. Thanks!

phelipetls avatar Nov 13 '22 16:11 phelipetls

Sorry, I'm not aware of a better way to handle this

MoustaphaDev avatar Nov 13 '22 21:11 MoustaphaDev

@Princesseuh can you take a look if this error message can be improved?

matthewp avatar Nov 14 '22 13:11 matthewp

This seems to be a compiler bug, maybe something to do with the export + the generic argument confusing the compiler?

Princesseuh avatar Nov 14 '22 13:11 Princesseuh

@Princesseuh Yeah that sounds right. I recall seeing this error message on generic types before 🤷

bholmesdev avatar Nov 17 '22 03:11 bholmesdev

Moving to the compiler repo. fwiw, removing the export makes it work. Exporting Props is unnecessary (it does nothing for editor tooling and never has) and generally unwanted, so I consider this a good workaround in this case. The Astro ESLint plugin should handle this better.

Princesseuh avatar Mar 23 '23 10:03 Princesseuh

Could be related to https://github.com/withastro/compiler/issues/554

Princesseuh avatar Nov 12 '23 22:11 Princesseuh