Skip to content

Merged Interfaces with incompatible methods and properties should be an error #20826

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
weswigham opened this issue Dec 20, 2017 · 3 comments
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@weswigham
Copy link
Member

weswigham commented Dec 20, 2017

TypeScript Version: 2.7.0-dev.201xxxxx

Code

interface Foo {
    bold(): string;
}

interface Foo {
    bold: string;
}

var x: Foo;

const j = x.bold;

Expected behavior:
j is type any, TS issues an error on both declarations of bold because their type doesn't match.

Actual behavior:
No error, j is type string.

Please note, the colors DT package (and one other package) relies on our current buggy behavior here and will need to be fixed.

@weswigham weswigham added the Bug A bug in TypeScript label Dec 20, 2017
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 20, 2017

This is a regression that seems to have started in TypeScript 2.0. TypeScript 1.8 is the last version that reported

error TS2300: Duplicate identifier 'bold'.

@weswigham
Copy link
Member Author

The bisect result says this was an (unintended?) side-effect of #8696. cc @RyanCavanaugh wasn't the restriction only supposed to be relaxed if the declarations had the same types?

@RyanCavanaugh
Copy link
Member

Correct, the intended behavior is that this would be an error due to the types not being identical

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants