Uh oh!
There was an error while loading. Please reload this page.
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
TypeScript Bot (typescript-bot)
commented
Dec 5, 2022
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.
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
| 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.
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
Andrew Branch (andrewbranch)
left a comment
There was a problem hiding this comment.
Good find 👍
Makes further improvements to what was implemented here: #48410
cc Andrew Branch (@andrewbranch)