Not sure if it is related to TypeScript version or VSCode version, but I have this piece of code where getCache() return type will be the actual return type of createCache() using getCache(): ReturnType<this["createCache"]>.
It works fine for sometime, but I'm not sure when, the type hint for getCache() does not resolve to the actual type of the overrode createCache(), and showed as a plain ReturnType<this["createCache"]> instead of { name: string, age: number }.
Sample code:
abstract class CacheManager {
getCache(): ReturnType<this['createCache']> {
return this.createCache()
}
abstract createCache(): any
}
class MyCacheManager extends CacheManager {
doSomething() {
const cache = this.getCache()
// should be { name: "John", age: 30 } or { name: string, age: number }
// instead of ReturnType<this["createCache"]>
}
override createCache() {
return { name: 'John', age: 30 }
}
}