Fix missing 'infer T' in declaration files#22764
Merged
Merged
Conversation
DanielRosenwasser
approved these changes
Mar 21, 2018
Member
|
Let's make sure this gets into |
weswigham
requested changes
Mar 21, 2018
Member
There was a problem hiding this comment.
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).
Member
Author
|
@weswigham Should be good now. |
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.
With this PR we properly emit
infer Tdeclarations in representations of instantiated conditional types.Additionally, we report errors on. Additionally, we now properly locate the owning conditional type for aninfer Tdeclarations in invalid locations within conditional types nested within other conditional typesinfer Tdeclaration: It is the innermost containing conditional type in whoseextendstype theinfer Tdeclaration occurs.Fixes #22755.