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: add # and numbers to ts store regex #473

Merged
merged 4 commits into from
Feb 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/transformers/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +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(/\$[a-zA-Z_][\w_$]*/g) || [],
contentForCodestores.match(
/\$[^\s();:,[\]{}.?!+\-=*/\\~|&%<>^`"'°§#1-9][^\s();:,[\]{}.?!+\-=*/\\~|&%<>^`"'°§#]*/g,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need the groups because while the variable can not start with a number, it can have a number after it

dummdidumm marked this conversation as resolved.
Show resolved Hide resolved
) || [],
(name) => name.slice(1),
).filter((name) => !JAVASCRIPT_RESERVED_KEYWORD_SET.has(name));

Expand Down