Skip to content

Allow indexing generics with unique symbols#22339

Merged
weswigham merged 2 commits into
microsoft:masterfrom
weswigham:allow-symbol-index
Mar 5, 2018
Merged

Allow indexing generics with unique symbols#22339
weswigham merged 2 commits into
microsoft:masterfrom
weswigham:allow-symbol-index

Conversation

@weswigham
Copy link
Copy Markdown
Member

Fixes #22320

Comment thread src/compiler/checker.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);
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member Author

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.

Comment thread src/compiler/checker.ts Outdated
getLiteralType(symbolName(prop));
const links = getSymbolLinks(prop);
if (!links.nameType) {
if (links.target && links.target.escapedName === prop.escapedName) {
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moved to debug assertion.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jun 8, 2018

I think you mean:

trie[letter][END_WORD] = END_VALUE;

instead of

trie[END_WORD] = END_VALUE;

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants