Skip to content

Commit

Permalink
fix: add # and numbers to ts store regex (#473)
Browse files Browse the repository at this point in the history
Fixes #466
  • Loading branch information
andr3h3nriqu3s11 committed Feb 2, 2022
1 parent 425b9a5 commit 881f3c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/transformers/typescript.ts
Expand Up @@ -152,8 +152,9 @@ function injectVarsToCode({
// TODO investigate if it's possible to achieve this with a
// TS transformer (previous attemps have failed)
const codestores = Array.from(
contentForCodestores.match(/\$[^\s();:,[\]{}.?!+\-=*/\\~|&%<>^`"'°§]+/g) ||
[],
contentForCodestores.match(
/\$[^\s();:,[\]{}.?!+\-=*/\\~|&%<>^`"'°§#0-9][^\s();:,[\]{}.?!+\-=*/\\~|&%<>^`"'°§#]*/g,
) || [],
(name) => name.slice(1),
).filter((name) => !JAVASCRIPT_RESERVED_KEYWORD_SET.has(name));

Expand Down
8 changes: 7 additions & 1 deletion test/fixtures/TypeScriptImports.svelte
Expand Up @@ -23,7 +23,13 @@
$in: "",
a: "$",
b: '$',
c: `$`
c: `$`,
d: "$#",
e: '$#',
f: `$#`,
g: "$1a",
h: '$2b',
i: `$3c`
};
let inputVal: string;
const action = (node: Element, options: { id: string; }) => { node.id = options.id; };
Expand Down

0 comments on commit 881f3c9

Please sign in to comment.