mirror of https://github.com/sveltejs/svelte
fix: don't error on `{type}` in declaration tags (#18321)
The `\b` in the regex matched on `}`, too, so you would get a very
confusing "invalid declaration tag" error on `{type}`. Match on
whitespace instead (because that's what has to come afterwards)
---------
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Rich-Harris <hello@rich-harris.dev>
pull/18322/head
parent
5300843e86
commit
980c7e2321
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"code": "declaration_tag_invalid_type",
|
||||
"message": "Declaration tags must be `let` or `const` declarations",
|
||||
"start": {
|
||||
"line": 14,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 14,
|
||||
"column": 8
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,15 @@
|
||||
{#if true}
|
||||
<!-- check that these doesn't trigger already -->
|
||||
{type}
|
||||
{type }
|
||||
{type && foo}
|
||||
{type || bar}
|
||||
{type % 2}
|
||||
{type .x}
|
||||
{type ?.x}
|
||||
{type ()}
|
||||
{type [1]}
|
||||
{type `tag`}
|
||||
<!-- ... this one should trigger though -->
|
||||
{type foo = boolean}
|
||||
{/if}
|
||||
Loading…
Reference in new issue