Improve string literal completions for property values when a partially-typed string fixes inference to a type parameter#51770
Merged
sandersn merged 1 commit intomicrosoft:mainfrom Dec 20, 2022
Conversation
…ly-typed string fixes inference to a type parameter
Collaborator
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
Andarist
commented
Dec 5, 2022
| /// <reference path="fourslash.ts" /> | ||
|
|
||
| // @Filename: /a.tsx | ||
| //// declare function bar1<P extends "" | "bar" | "baz">(p: { type: P }): void; |
Contributor
Author
There was a problem hiding this comment.
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
Andarist
commented
Dec 5, 2022
| return (parent as CaseClause).expression === node ? getSwitchedType(parent as CaseClause, checker) : undefined; | ||
| default: | ||
| return checker.getContextualType(node); | ||
| return checker.getContextualType(node, contextFlags); |
Contributor
Author
There was a problem hiding this comment.
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
sandersn
approved these changes
Dec 20, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes further improvements to what was implemented here: #48410
cc @andrewbranch