Skip to content

Trimmed leading and trailing spaces when reading string literals after "[" and added a test case. #62144

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

falshami2002
Copy link

Fixes #62101

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 29, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jul 29, 2025
@falshami2002
Copy link
Author

@microsoft-github-policy-service agree

@falshami2002
Copy link
Author

It looks like one check failed, but the logs indicate "429 (Too many requests)". This is my first contribution, so let me know if anything is needed on my end, or if there was anything I could do better. Thank you for your time.

@DanielRosenwasser
Copy link
Member

I'm not sure how the name includes spaces to begin with. Does this do "the right thing" if there is a comment on either side of the string?

@falshami2002
Copy link
Author

@DanielRosenwasser I double checked with test cases of [ "x" ] and [ /--comment1--/ "x" /--comment2--/]. Everything appears to work correctly. It looks like symbolName begins as: ["x" ]. After going through the if statement in line 8860, we end up with substring(1, len - 1) which ends up being "x"/space/. When we trim before passing into stripQuotes in the if block starting at line 8865, it allows stripQuotes to function correctly. stripQuotes checks for name.charCodeAt(0) === name.charCodeAt(length - 1), so if we don't strip, we are comparing " to /space/ and it just returns the original string, without stripping. createStringLiteral then adds it's own quotes on top of that and escapes the existing ones, giving us the output in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Adding a space after the string literal in a computed property name causes an incorrect hover display
3 participants