-
-
Notifications
You must be signed in to change notification settings - Fork 223
Description
Describe the bug
When using certain regular expressions (specifically pattern) in Svelte TypeScript files, the TypeScript language service encounters a parsing error that completely breaks variable declaration recognition throughout the entire file. This causes all variables and functions in the template to be marked as "Cannot find name" even though the code compiles and runs correctly.
Reproduction
Create a Svelte file with TypeScript
Add a regular expression containing
function testFunction(content: string) {
if (/<!DOCTYPE html>/i.test(content)) { // ❌ This line triggers the bug
return "html";// ❌ IDE reports : "Expression expected."
}
return "json";
}Add variables and use them in template:
let testVariable = "hello"; // ✅ This should work
<div>{testVariable}</div> <!-- ❌ IDE reports "Cannot find name 'testVariable'" -->
Expected behaviour
No TypeScript parsing errors
All variables should be properly recognized in the template
System Info
OS: Windows 11
IDE: VS Code / Cursor 1.2.1
Svelte for VS Code 109.9.0
Which package is the issue about?
Svelte for VS Code extension
Additional Information, eg. Screenshots
