Skip to content

Diagnostic elaboration is not consistently reported in language service #3276

Closed
@DanielRosenwasser

Description

@DanielRosenwasser

Adapted from #3275:

class GenericThingamabob<T> {
    constructor(private entity: T) {}
    add(item: T) { }
}

class CouponInfo {
    private couponTag: {};
}

class Snake {
    private snakeTag: {};
}

var blah = new GenericThingamabob(new CouponInfo());

blah.add(new Snake());
//       ~~~~~~~~~~~
var x: CouponInfo = new Snake();
//  ~

On the first error, I get

Argument of type 'Snake' is not assignable to parameter of type 'CouponInfo'.
  Property 'couponTag' is missing in type 'Snake'

On the second, I get

Type 'Snake' is not assignable to type 'CouponInfo'.

Note that if you turned blah.add(new Snake()); into a variable assignment like var a: CouponInfo = new Snake(), you'll get the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions