-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix missing 'infer T' in declaration files #22764
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
Conversation
Let's make sure this gets into |
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.
export type BadNested<T> = {x: T extends number ? T : string};
export declare function foo<T>(obj: T): T extends {[K in keyof BadNested<infer P>]: BadNested<infer P>[K]} ? P : never;
export function bar<T>(obj: T) {
return foo(obj);
}
will still emit invalid declarations for bar
(but issue no errors), since we happily inline aliases from time-to-time (even though this breaks conditional types under their current scoping rules). The only real fix I see is to make aliases actually inlinable again by allowing infer
types in the other conditional type clauses, but correctly scoping them to the outer scope (rather than them being a deadzone like they are with this PR).
@weswigham Should be good now. |
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.
👍
With this PR we properly emit
infer T
declarations in representations of instantiated conditional types.Additionally, we report errors on. Additionally, we now properly locate the owning conditional type for aninfer T
declarations in invalid locations within conditional types nested within other conditional typesinfer T
declaration: It is the innermost containing conditional type in whoseextends
type theinfer T
declaration occurs.Fixes #22755.