Skip to content

This condition will always return 'false' since the types have no overlap. #25642

@Busyrev

Description

@Busyrev

TypeScript Version: 3.0.0-dev.20180712
Error: This condition will always return 'false' since the types 'A' and 'I' have no overlap.
TypeScript Version: 2.9.2
Error: Operator '===' cannot be applied to types 'A' and 'I'

Search Terms:
Operator '===' cannot be applied to types
This condition will always return 'false' since the types have no overlap.
Code

class A { 
  private field: string;
}
interface I { 
  pub: string;
}
class B extends A implements I { 
  pub: string;
}
let b = new B();
let a: A = b
let i: I = b;
if (a === i) { // on TS 2.9.2: Operator '===' cannot be applied to types 'A' and 'I'
// on TS 3.0.0-dev.20180712:  This condition will always return 'false' since the types 'A' and 'I' have no overlap.
  console.log('qq');
}

Expected behavior:
no error
Actual behavior:
error
Playground Link: link

Related Issues: no

This case found from real project. Class and interface may be implemented and extended by another class, and in this case this error is pointless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions