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

Conversation

andr3h3nriqu3s11
Copy link
Contributor

Fixes #466

And also fixes another situation that led me to research this issue. Where something like this

let str = "$1$2";

or

let str = "$1a";

would result in a type error (TS1351) where it was assuming that 1$2 was a variable where it should not

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests with npm test or yarn test

@andr3h3nriqu3s11
Copy link
Contributor Author

I don't know if this is worth a new issue, but these errors also happen when the code is commented.

@@ -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 dummdidumm merged commit 881f3c9 into sveltejs:main Feb 2, 2022
@dummdidumm
Copy link
Member

Thank you!

@andr3h3nriqu3s11 andr3h3nriqu3s11 deleted the fix-ts-regex branch February 2, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v4.9.0 onward invalid character error when using a dollar sign followed by a symbol (e.g. "$#")
2 participants