language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Non-ternary conditional template causes `astro check` error

Open DerYeger opened this issue 3 years ago • 2 comments

What version of astro are you using?

1.0.5

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

None

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

Using non-ternary conditional expressions in templates works fine, but shows errors when running astro check (no default export).

The following works fine, but results in an error.

{someCondition && <span>Hello</span>}
{someCondition && <span>World</span>}

This line also works fine but does not result in an error.

{someCondition ? <span>Hello</span> : <span>World</span>}

Link to Minimal Reproducible Example

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

Participation

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

DerYeger avatar Aug 17 '22 12:08 DerYeger

Hello, thank you for filling this issue. This is an issue with how we parse files in the Astro language server at the moment. We're currently in the progress of migrating to a new parser that should fix this issue!

You can track progress on that here https://github.com/withastro/language-tools/pull/335

I'm sorry for the inconvenience 😅

Princesseuh avatar Aug 17 '22 13:08 Princesseuh

Hello, thank you for filling this issue. This is an issue with how we parse files in the Astro language server at the moment. We're currently in the progress of migrating to a new parser that should fix this issue!

You can track progress on that here https://github.com/withastro/language-tools/pull/335

I'm sorry for the inconvenience 😅

It wasn't an inconvenience at all and actually made me refactor my code for better readability. Thanks for your work!

DerYeger avatar Aug 17 '22 15:08 DerYeger

Fixed by https://github.com/withastro/language-tools/pull/335

Princesseuh avatar Nov 14 '22 19:11 Princesseuh