Skip to content

Call on OR type rejected without obvious reason. #11005

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

Closed
dbaeumer opened this issue Sep 20, 2016 · 3 comments
Closed

Call on OR type rejected without obvious reason. #11005

dbaeumer opened this issue Sep 20, 2016 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@dbaeumer
Copy link
Member

TypeScript Version: 2.0.2
Code

interface I1 {
    openEditor(input: string, options: string | number): void;
}

interface I2 {
    openEditor(input: string, options: string): void;
}

let part: I1 | I2;

part.openEditor('dirk', 'baeumer');

You get a compile error on part.openEditor. However I think the call should be accepted since the interface could be correctly merged.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Sep 20, 2016
@RyanCavanaugh
Copy link
Member

Duplicate of #7294

@dbaeumer
Copy link
Member Author

@RyanCavanaugh @mhegazy just wanted to point out that the code above worked in 1.8.10. So in that regard it is not a dup of #7294

@RyanCavanaugh
Copy link
Member

There was a change in how we do subtype reduction. The type I1 | I2 is actually somehwat meaningless (I1 is strictly more general) and it was previously reduced immediately to I1, but that had other bad side effects (namely, if you narrow away I1, you'd get neverinstead of I2)

@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.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants