-
Notifications
You must be signed in to change notification settings - Fork 1.8k
TS: fix a case of infinite type expansion #1059
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
TS: fix a case of infinite type expansion #1059
Conversation
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.
LGTM.
- do we want this as a hotfix for 1.20?
- does it require a change note?
* Returns `true` if the properties of the given type can safely be extracted | ||
* without restricting expansion depth. | ||
* | ||
* This predicate is very approximate, and considers all unions, intersections, |
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.
Very approximate indeed.
Maybe we should look into special casing on some common cases later.
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.
It shouldn't be that bad. The structure of a type is still extracted, this just determines whether its properties are. So for a type like Buffer | string
, we can still tell it's a Buffer | string
, but we won't necessarily compute the members of the union itself (i.e. the intersection of members on Buffer
and string
).
Also, members are always computed for types directly referenced from the AST, for example, if some expression is inferred to have the type A & B
, that type is fully extracted, members and all, but A
and B
themselves might be shallow.
(edited for a better example)
ca1dbee
to
16a2177
Compare
Rebased on 1.20. I'm not sure a change note is warranted, given that not many people use full-mode extraction anyway. |
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.
LGTM; let's skip the change note.
Fixes a problem observed when extracting DefinitelyTyped in full mode.