-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
with infer in template string, suggestion works in 4.6, but not work in 4.7 #49680
Comments
This doesn't seem to be due to |
Note that we have no suggestions in 4.7.4 for |
No, not intended. The nonlinearity of conditional types makes it impossible to guess with any certainty whether a wider or narrower instantiation is going to produce better completions... maybe we ought to do both and concatenate the results. |
We have also come across a somewhat similar case where the list of suggestions in TS 4.7 (and 4.8) is no longer the same as it was in TS 4.6. declare function pick<T extends object, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
const obj = { aaa: 1, bbb: '2', ccc: true };
pick(obj, 'aaa', ''); // suggestions inside the empty string
// TS 4.6: aaa, bbb, ccc
// TS 4.7: aaa It is worth noting that if I rewrite Another way to get around the issue is to use a slightly different definition for declare function pick<T extends object, K extends (keyof T)[]>(obj: T, ...keys: K): Pick<T, K[number]>; It's unfortunate that the (seemingly) more natural definition of |
Can this task get a higher priority? |
@dmitri-gb's and @wwwouter's cases are somewhat different from the OP. The problem with those 2 is that the type param is being used as rest but only the "current" argument is being "blocked". If all arguments typed through this rest would get blocked then it would work OK. At the same time... it's not that hard to imagine that a different piece within a given call could fix the inference in a similar way, so fixing this specific case by blocking sibling arguments that are typed through the same rest wouldn't necessarily fix the whole issue. OTOH, this particular use case is probably more common than those other cases so perhaps it would still be worth exploring this as a solution right now. |
Bug Report
π Search Terms
suggestion pathof
π Version & Regression Information
4.7
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
π Expected behavior
The text was updated successfully, but these errors were encountered: