-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Return string completions for indexed access types #20941
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
Return string completions for indexed access types #20941
Conversation
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.
Looks good! Though I would also rename the test completionForStringLiteral14.ts
to completionForStringLiteralInIndexedAccess01.ts
src/services/completions.ts
Outdated
@@ -360,6 +369,18 @@ namespace ts.Completions { | |||
return undefined; | |||
} | |||
|
|||
function getStringLiteralCompletionsFromIndexedAccess(node: IndexedAccessTypeNode, typeChecker: TypeChecker, target: ScriptTarget, log: Log): CompletionInfo | undefined { |
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 mostly the same as getStringLiteralCompletionEntriesFromElementAccess
, I would combine them into getStringLiteralCompletionEntriesFromElementAccessOrIndexedAccess
, and call them with the appropriate type
and stringLiteralNode
.
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.
That definitely makes sense. Would you be okay with stringLiteralNode: Node
as a parameter, or would you prefer stringLiteralNode: StringLiteral | NoSubstitutionTemplateLiteral
?
613f15d
to
73d4461
Compare
@DanielRosenwasser I've updated the PR based on your feedback. Instead of doing manual |
@mariusschulz can you please refresh the PR and address the merge conflicts |
73d4461
to
be0c57d
Compare
be0c57d
to
25c5e57
Compare
@mhegazy Sure, done! |
Thanks Marius! |
Fixes #20938
This PR provides string literal completions within indexed access types.
Does this look good to you, @DanielRosenwasser? Let me know if you need me to add anything else.