Closed
Description
TypeScript Version: 3.3.0-dev.20181208
Search Terms: constructor interface this extends sub class
Code
interface AConstructor {
new (): AInstance
a(): this
}
interface AInstance {
a: string
}
declare const A: AConstructor
declare function test<T extends typeof A>(a: T): T
class B extends A {
b: string
}
const B1: typeof B = B.a() // Unexpected: Return type is AConstructor
const B2: typeof B = test(B) // Unexpected: Type parameter is inferred to AConstructor
Expected behavior:
The return type of B.a()
and test(B)
is typeof B
.
Actual behavior:
The return type of B.a()
and test(B)
is AConstructor
.
Related Issues:
vuejs/vue-class-component#294
Background: I've found this behaviour while investigating the above issue. This is caused by recent changes for Vue's type declaration. It looks like the extending class does not match with the decorator type because this
type is still base constructor type.
I'm still not sure if my guess is correct. If it is not true, please just let me know about that.