Skip to content

Commit 85a86c8

Browse files
authored
fix: adjust store regex (#441)
Don't match in the case of $° or $§ or $\, these are not store variables Fixes #433
1 parent f6ef334 commit 85a86c8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: src/transformers/typescript.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ function injectVarsToCode({
152152
// TODO investigate if it's possible to achieve this with a
153153
// TS transformer (previous attemps have failed)
154154
const codestores = Array.from(
155-
contentForCodestores.match(/\$[^\s();:,[\]{}.?!+-=*/~|&%<>^`"']+/g) || [],
155+
contentForCodestores.match(/\$[^\s();:,[\]{}.?!+-=*/\\~|&%<>^`"'°§]+/g) ||
156+
[],
156157
(name) => name.slice(1),
157158
).filter((name) => !JAVASCRIPT_RESERVED_KEYWORD_SET.has(name));
158159

Diff for: test/fixtures/TypeScriptImports.svelte

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
}
4040
$storeScriptOnly;
4141
$storeModuleScriptOnly;
42+
43+
// These shouldn't count as store values:
44+
// $\\; $$; $§; $%; $°; $(; $); $[; $]; $<; $>; $ ; $^; $`; $"; $';
45+
// These don't need to be tested explicitly, the test will throw and error
46+
// at the TypeScript parsing stage if they are part of the false positives
4247
</script>
4348

4449
<style>

0 commit comments

Comments
 (0)