withastro / language-tools

Language tools for Astro
MIT License
267 stars 52 forks source link

🐛 BUG: TS Tries To Parse Code In `<pre>` Tags #884

Closed fweth closed 3 months ago

fweth commented 3 months ago

Describe the Bug

When I have this in an .astro file

<pre>
 {
    int i = 13 ;
    { 
       int i = 42 ; 
       print(i) ;
    }
    print(i) ;
 }
 </pre>

I see TS errors like Cannot find name 'int'. Did you mean 'Intl'?ts(2552). When I switch the language mode to HTML, those errors disappear.

Steps to Reproduce

Paste some (faulty) code inside <pre> tags in some .astro file.

Princesseuh commented 3 months ago

I'm not sure I understand, even though this is a pre tag, this creates an expression, so it's normal for the extension to try to parse it as TypeScript. Astro itself will also do that, pasting your snippet in a Astro file, you'll get an error like Expected "}" but found "i" or similar.

You might be looking for the is:raw attribute.