Skip to content

Fix react-redux break on DT #30375

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

Merged
merged 2 commits into from
Mar 13, 2019

Conversation

weswigham
Copy link
Member

This is my attempt for a fix that doesn't revert #30334. Rather than identifying where we're triggering a new instantiation, I've simply made conditional types more gracefully handle circular instantiations (which tbh I am surprised we didn't have a guard for already).

Fixes #30372

@weswigham
Copy link
Member Author

@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 13, 2019

Heya @weswigham, I've started to run the Definitely Typed test suite on this PR at d0d10b8. You can monitor the build here. It should now contribute to this PR's status checks.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a reasonable change. A question about the baseline changes.

// Repro from #25291

type PromisedTuple<L extends any[], U = (...args: L) => void> =
U extends (h: infer H, ...args: infer R) => [Promise<H>, ...PromisedTuple<R>] ? [] : []
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that all these circular reference errors go away because the types are now deferred? Does this example end up with no error because the rest of the program never uses PromisedTuple, or because the error was not necessary in the first place?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It goes away because the type is deferred now, yes. getReturnTypeOfSignature needs to be recurred into to trigger the error - but now, we ask for the return type, get the conditional, attempt to simplify the conditional, see the conditional instantiate itself into itself as part of one of its branch types, then go "nope, definitely won't simplify" and give it its deferred type, which is then what we return. Since we never actually inspect the resolved type of that inner instantiation (since we went "ah, it's going to be the same as one that's already resolving"), we never assigned it the circularity error.

@weswigham
Copy link
Member Author

The DT run is clean - the only breaks are the ramda changes from two days ago that #30363 should hopefully fix.

@weswigham weswigham merged commit 5d08b68 into microsoft:master Mar 13, 2019
@weswigham weswigham deleted the fix-conditional-reentrancy branch March 13, 2019 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DT nightly: many new excessively deep instantiation errors
3 participants