When I assign a partial value to a variable that is declared with a partial type, its type remains partial:
let x: { a: string, b?: string }
x = { a: "a" }
x.b // fine, x <=> {a:string, b?:string}
The same with a class property:
class X {
prop: { a: string, b?: string } = { a: "a" }
}
(new X).prop.b // fine, prop <=> {a:string, b?:string}
However, an inherited property doesn't seem to follow this rule and assigns the exact type instead:
class Y extends X {
prop = { a: "a" }
}
(new Y).prop.b // FAIL, prop <=> {a:string}
How can this behaviour be explained?