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

🐛 BUG: Shorthand syntax for props is not supported

Open Princesseuh opened this issue 2 years ago • 2 comments

Describe the Bug

Trying to use the shorthand syntax for props currently lead to an error, ex:

<Component {myProp}/>

We should support this, especially since it's a possible formatting result from the Prettier plugin

Steps to Reproduce

  1. Create an Astro project
  2. Create a component with a prop
  3. Try to pass a prop using shorthand syntax
  4. Error!

Princesseuh avatar Mar 23 '22 16:03 Princesseuh

I haven't had a chance to properly test this yet, but I think this regex would do the trick \s{(?'variable'[a-zA-Z_$][a-zA-Z_$0-9]*)}

tony-sull avatar Apr 04 '22 17:04 tony-sull

Here is a reproduction of the issue. It should automatically run astro check to see the issue.

https://stackblitz.com/edit/github-jcxxvc?file=src%2Fpages%2Findex.astro&on=stackblitz

It seems like the language tools extension is interpreting the values as the props themselves.

jonathantneal avatar Aug 26 '22 20:08 jonathantneal