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

Unhelpful extra error that class prototype isn't assignable to superclass prototype #26138

Closed
ghost opened this issue Aug 1, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue

Comments

@ghost
Copy link

ghost commented Aug 1, 2018

TypeScript Version: 3.1.0-dev.20180801

Code

interface A {
    n: number;
}
declare var A: {
    prototype: A;
    new(): A;
};

class B extends A {
    n = "";
}

Expected behavior:

One error: Property 'n' in type 'B' is not assignable to the same property in base type 'A'.

Actual behavior:

Two errors:

src/a.ts:9:7 - error TS2417: Class static side 'typeof B' incorrectly extends base class static side '{ prototype: A; }'.
  Types of property 'prototype' are incompatible.
    Type 'B' is not assignable to type 'A'.
      Types of property 'n' are incompatible.
        Type 'string' is not assignable to type 'number'.

9 class B extends A {
        ~

src/a.ts:10:5 - error TS2416: Property 'n' in type 'B' is not assignable to the same property in base type 'A'.
  Type 'string' is not assignable to type 'number'.

10     n = "";

We could just omit static-side errors if instance-side errors exist.

@ghost ghost added Suggestion An idea for TypeScript Domain: Error Messages The issue relates to error messaging labels Aug 1, 2018
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript and removed Suggestion An idea for TypeScript labels Aug 2, 2018
@RyanCavanaugh
Copy link
Member

Seems unambiguously better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants