Closed
Description
TypeScript Version:
1.8.7
Code
'use strict';
class User {
firstName: string;
lastName: string;
static getInstance() {
return new this();
}
}
class StaffUser extends User {
position: string;
}
let staffUser = StaffUser.getInstance();
console.log(staffUser.position); // error TS2339: Property 'position' does not exist on type 'User'
Expected behavior:
staffUser
should be of type StaffUser
, not simply User
.
Actual behavior:
The compiler doesn't guess that getInstance
in StaffUser
returns instances of StaffUser
.