withastro / language-tools

Language tools for Astro
MIT License
240 stars 45 forks source link

🐛 BUG:Error reported for attribute vscode #886

Closed ajiho closed 1 week ago

ajiho commented 1 week ago

Describe the Bug

image

不能将类型“{ children: any[]; lang: string; myattr: any; }”分配给类型“HtmlHTMLAttributes”。
  类型“HtmlHTMLAttributes”上不存在属性“myattr”。ts(2322)

Why? This syntax can be compiled in Astro, but vscode reports an error, which I think is very unreasonable

Steps to Reproduce

Princesseuh commented 1 week ago

Because the html element doesn't take that attribute normally. The type checking checks for standard attributes.

You can extend the type definition by following the second part of this section: https://docs.astro.build/en/guides/typescript/#built-in-html-attributes