Why is this.name underlined with the following error?
Type 'string | null' is not assignable to type 'If<Ready, string, null>'.
Type 'null' is not assignable to type 'If<Ready, string, null>'.ts(2322)
Code:
type If<T extends boolean, A, B = null> = T extends true ? A : T extends false ? B : A | B;
class User<Ready extends boolean> {
public name: If<Ready, string, null>;
public constructor(name?: string) {
this.name = name ?? null;
}
}