Open
Description
TypeScript Version: 3.2.0-dev.20181011
Search Terms: TS2367
Code
abstract class Base<T> {
get Item(): T { return null }
}
class Child extends Base<Item> {
constructor(public data: any) { super() }
}
interface Item { }
declare type Constructor<T> = new (data: any) => Base<T>
function func<T>(constructor: Constructor<T>): void {
// TS2367: This condition will always return 'false' since the types 'Constructor<T>' and 'typeof Child' have no overlap.
if (constructor === Child) {
// do something
}
new constructor(null)
}
func(Child) // No errors
Expected behavior:
Compiles without errors.
Actual behavior:
test.ts:14:9 - error TS2367: This condition will always return 'false' since the types 'Constructor<T>' and 'typeof Child' have no overlap.
14 if (constructor === Child) {
~~~~~~~~~~~~~~~~~~~~~
Related Issues: #25642