Skip to content
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

Fix conditional type simplification #30877

Merged
merged 3 commits into from Apr 12, 2019
Merged

Conversation

ahejlsberg
Copy link
Member

This PR switches conditional type simplification to use an object identity check instead of isTypeIdenticalTo. This is slightly more restrictive but certainly will never cause runaway recursion and doesn't appear to affect the scenarios we care about.

It would of course be nice to revise isTypeIdenticalTo to avoid the runaway recursion, but meanwhile I think this is a good fix.

Fixes #30794.

@ahejlsberg
Copy link
Member Author

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 12, 2019

Heya @ahejlsberg, I've started to run the extended test suite on this PR at 06d07b0. You can monitor the build here. It should now contribute to this PR's status checks.

@ahejlsberg
Copy link
Member Author

@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 12, 2019

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

@ahejlsberg
Copy link
Member Author

No changes to the RWC baselines (errors are identical).

@ahejlsberg
Copy link
Member Author

The DT errors appear to be existing issues unrelated to this PR. So, overall, RWC and DT look good.

@RyanCavanaugh
Copy link
Member

Let's pull this one in for 3.4.4 as well

@weswigham
Copy link
Member

weswigham commented Apr 12, 2019

It would of course be nice to revise isTypeIdenticalTo to avoid the runaway recursion, but meanwhile I think this is a good fix.

I'd tried that locally (it was just a matter of making variance checking smarter in identity mode when I was looking) and it was never actually enough for what I was trying to fix at the time - (the actual instantiations were ultimately what cost). I can try opening that here if you think that's all that's needed to fix this issue.

In any case, if you port this to 3.4, I think it'd be a good idea to port substitution cacheing as well.

@RyanCavanaugh
Copy link
Member

@ahejlsberg mostly for curiosity - now that we know the fix, is it possible to construct a simpler repro?

@ahejlsberg ahejlsberg merged commit 4574c7a into master Apr 12, 2019
@ahejlsberg ahejlsberg deleted the fixConditionalTypeSimplification branch April 12, 2019 17:35
RyanCavanaugh pushed a commit to RyanCavanaugh/TypeScript that referenced this pull request Apr 12, 2019
…implification

Fix conditional type simplification
@RyanCavanaugh RyanCavanaugh mentioned this pull request Apr 12, 2019
RyanCavanaugh added a commit that referenced this pull request Apr 16, 2019
Ports #30877 to release-3.4
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.

JavaScript heap out of memory when compiling typesafe-joi on v3.4.x
4 participants