GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix union/union or intersection/intersection type inference by ahejlsberg · Pull Request #5942 · microsoft/TypeScript

Conversation

@ahejlsberg

@ahejlsberg Anders Hejlsberg (ahejlsberg) commented Dec 5, 2015

Copy link
Copy Markdown
Member

The reduction step introduced in #5738 is a bit too aggressive. For example:

interface Foo<T> {
    x: T;
}

function bar<T>(x: Foo<T> | string): T {
    return bar(x);
}

In the bar(x) call we infer from Foo<T> | string to Foo<T> | string which previously was reduced to empty types (and thus no inferences) because all constituents are pairwise identical. Therefore, the above would be an error. With this PR we instead find all of the pairwise identical constituents and infer from each match to itself. We then remove the pairwise matches and proceed with the already existing inference algorithm.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Anders Hejlsberg (ahejlsberg) added 2 commits December 4, 2015 16:04
@ahejlsberg
Fix union/union and intersection/intersection type inference
e6259a5
@ahejlsberg
Adding test
ae9d93b
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Dec 5, 2015
@ahejlsberg Anders Hejlsberg (ahejlsberg) added this to the TypeScript 1.8 milestone Dec 5, 2015
@ahejlsberg Anders Hejlsberg (ahejlsberg) assigned Anders Hejlsberg (ahejlsberg) and unassigned Anders Hejlsberg (ahejlsberg) Dec 5, 2015
@mhegazy

Mohamed Hegazy (mhegazy) commented Dec 5, 2015

Copy link
Copy Markdown
Contributor

👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

1 similar comment
@vladima

Vladimir Matveev (vladima) commented Dec 5, 2015

Copy link
Copy Markdown
Contributor

👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ahejlsberg
Adding a bit more text to comments
6901a98
Anders Hejlsberg (ahejlsberg) added a commit that referenced this pull request Dec 5, 2015
@ahejlsberg
Merge pull request #5942 from Microsoft/fixUnionToUnionTypeInference
3ce91c4
Fix union/union or intersection/intersection type inference
@ahejlsberg
Anders Hejlsberg (ahejlsberg) merged commit 3ce91c4 into master Dec 5, 2015
@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the fixUnionToUnionTypeInference branch December 5, 2015 17:28
@ahejlsberg Anders Hejlsberg (ahejlsberg) mentioned this pull request Dec 7, 2015
TypeScript compiler hangs case #4604
Closed
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

TypeScript 1.8

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@ahejlsberg @mhegazy @vladima @msftclas
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.