-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Closed
Copy link
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: 2.3.2
Code
class A { public x:number; }
class B { private x:number; }
let a:A = new A as Readonly<A>; // succeeds
let b:B = new B as Readonly<B>; // type error: Property x is missing in Readonly<B>
class AA { private x:number; }
class BB extends AA {}
let bb:BB = new BB as Readonly<BB>; // type error: Property x is missing in Readonly<BB>
Expected behavior:
To me it appears B and its Readonly are the same (since there are no external visible properties) while A and its Readonly differ in the mutability in x. Although I also think it would be fine if all assignments worked.
I actually noticed this with the case of BB and it being a private field in the super class that caused the assignment to fail.
Actual behavior:
As per code comments
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed