From 9f2d7a07053b8f010067bf7e55d99bccb2958567 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 8 Sep 2021 23:03:57 +0200 Subject: [PATCH] fix: add quotes to ts store regex (#403) Fixes #402 Co-authored-by: Simon Holthausen --- src/transformers/typescript.ts | 2 +- test/fixtures/TypeScriptImports.svelte | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/transformers/typescript.ts b/src/transformers/typescript.ts index 0dd833b4..32074745 100644 --- a/src/transformers/typescript.ts +++ b/src/transformers/typescript.ts @@ -138,7 +138,7 @@ function injectVarsToCode({ // TODO investigate if it's possible to achieve this with a // TS transformer (previous attemps have failed) const codestores = Array.from( - content.match(/\$[^\s();:,[\]{}.?!+-=*/~|&%<>^]+/g) || [], + content.match(/\$[^\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 755ff47d..835e56fc 100644 --- a/test/fixtures/TypeScriptImports.svelte +++ b/test/fixtures/TypeScriptImports.svelte @@ -19,7 +19,10 @@ const obj = { fn: () => "test", val: "test1" as const, - $in: "" + $in: "", + a: "$", + b: '$', + c: `$` }; let inputVal: string; const action = (node: Element, options: { id: string; }) => { node.id = options.id; };