You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@RyanCavanaugh@weswigham
I found a new issue. The correct type cannot be inferred without using readonly.
Is this an expected behavior?
Should I open a new issue?
export type LibObjectType = 'Circle' | 'Square';
export interface LibObject {
type: LibObjectType;
id: number;
}
export class LibCircle implements LibObject {
type = 'Circle';
id: number = Date.now();
}
export class LibSquare implements LibObject {
type = 'Square';
id: number = Date.now();
}
That's expected. Mutable locations widen literal types to their base unless appropriately contextually typed, and class properties aren't coming contextualized by their base. We have a bunch of discussions open on that.
TypeScript Version: 3.1.0-dev.20180818
Search Terms: description file class type interface implements
Code
Expected behavior:
Actual behavior:
Playground Link:
https://github.com/ZSkycat/issue-typescript-20180821-1
Related Issues:
The text was updated successfully, but these errors were encountered: