Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ts preprocessor to consider store suffixed with number #461

Merged
merged 1 commit into from Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/transformers/typescript.ts
Expand Up @@ -152,7 +152,7 @@ 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();:,[\]{}.?!+\-=*/\\~|&%<>^`"'°§]+/g) ||
[],
(name) => name.slice(1),
).filter((name) => !JAVASCRIPT_RESERVED_KEYWORD_SET.has(name));
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/TypeScriptImports.svelte
Expand Up @@ -10,7 +10,7 @@
import Nested from "./Nested.svelte";
import { hello } from "./script";
import { AValue, AType } from "./types";
import { storeTemplateOnly, storeScriptOnly } from "./store";
import { storeTemplateOnly, storeScriptOnly, store0 } from "./store";
import { onlyUsedInModuleScript } from "./modulescript";
const ui = { MyNested: Nested };
const val: AType = "test1";
Expand Down Expand Up @@ -39,6 +39,7 @@
}
$storeScriptOnly;
$storeModuleScriptOnly;
$store0;

// These shouldn't count as store values:
// $\\; $$; $§; $%; $°; $(; $); $[; $]; $<; $>; $ ; $^; $`; $"; $';
Expand Down
2 changes: 1 addition & 1 deletion test/transformers/typescript.test.ts
Expand Up @@ -129,7 +129,7 @@ describe('transformer - typescript', () => {
expect(code).toContain(`import { hello } from "./script"`);
expect(code).toContain(`import { AValue } from "./types"`);
expect(code).toContain(
`import { storeTemplateOnly, storeScriptOnly } from "./store"`,
`import { storeTemplateOnly, storeScriptOnly, store0 } from "./store"`,
);
expect(code).toContain(
`import { onlyUsedInModuleScript } from "./modulescript";`,
Expand Down