GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — Allow quoted names in completions · Pull Request #18162 · microsoft/TypeScript Conversation
|
| } | ||
|
|
||
| function isNumericLiteralText(name: string): boolean { | ||
| return /^-?\d+(\.\d+)?(e\d+)?$/.test(name); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
There are contexts like property names:
const foob = { -0() { return 1; } };
where a leading minus would never be allowed (only an identifier, string literal, or number) - I don't think this should include the check for -??
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also, this helper probably should be somewhere central, since it will need to be updated once we support the numeric seperator proposal.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We can just use a string literal in this case then, which makes this function unnecessary. 👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…nd use string literals for number keys
| // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. | ||
| if (performCharacterChecks && !isIdentifierText(name, target)) { | ||
| return undefined; | ||
| return allowStringLiteral ? JSON.stringify(name) : undefined; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
that would be another place where a user-defined quote setting will need to be honored.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.