diff --git a/src/transformers/typescript.ts b/src/transformers/typescript.ts index 8e128270..7846f371 100644 --- a/src/transformers/typescript.ts +++ b/src/transformers/typescript.ts @@ -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)); diff --git a/test/fixtures/TypeScriptImports.svelte b/test/fixtures/TypeScriptImports.svelte index 76538343..4419727e 100644 --- a/test/fixtures/TypeScriptImports.svelte +++ b/test/fixtures/TypeScriptImports.svelte @@ -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; };