-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Improve string literal completions for property values when a partially-typed string fixes inference to a type parameter #51770
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve string literal completions for property values when a partially-typed string fixes inference to a type parameter #51770
Conversation
…ly-typed string fixes inference to a type parameter
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
/// <reference path="fourslash.ts" /> | ||
|
||
// @Filename: /a.tsx | ||
//// declare function bar1<P extends "" | "bar" | "baz">(p: { type: P }): void; |
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.
notice how this test is almost identical to the one here:
https://github.com/microsoft/TypeScript/pull/48811/files#diff-a3a2637795672382fb54d54c328d2aff49256e2ce89a12cc7b5e636da2dd48ce
the only difference is that the argument here is p: { type: P }
where that linked one uses p: P
} | ||
case SyntaxKind.CaseClause: | ||
return (parent as CaseClause).expression === node ? getSwitchedType(parent as CaseClause, checker) : undefined; | ||
default: | ||
return checker.getContextualType(node); | ||
return checker.getContextualType(node, contextFlags); |
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.
The added test case only relies on this one. However, I've passed around contextFlags
to all other checker.getContextualType
calls in this function 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.
Good find 👍
Makes further improvements to what was implemented here: #48410
cc @andrewbranch