-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow indexing generics with unique symbols #22339
Conversation
@@ -5948,7 +5954,7 @@ namespace ts { | |||
// If the current iteration type constituent is a string literal type, create a property. | |||
// Otherwise, for type string create a string index signature. | |||
if (t.flags & TypeFlags.StringLiteral) { | |||
const propName = escapeLeadingUnderscores((<StringLiteralType>t).value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a StringLiteral
, does this need to be changed? Is it just for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly, yeah. The function below is used up above in the same body and is the correct one to use for future support of symbols as mapped type keys.
src/compiler/checker.ts
Outdated
getLiteralType(symbolName(prop)); | ||
const links = getSymbolLinks(prop); | ||
if (!links.nameType) { | ||
if (links.target && links.target.escapedName === prop.escapedName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't have to check names here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to debug assertion.
I think you mean: trie[letter][END_WORD] = END_VALUE; instead of trie[END_WORD] = END_VALUE; |
Fixes #22320