-
Couldn't load subscription status.
- Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
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.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created