I am reading the typescript handbook and came across the following code.
declare function create(o: object | null): void;
create({ prop: 0 });
create(null);
create(undefined); // Remember, undefined is a subtype of null
Argument of type 'undefined' is not assignable to parameter of type 'object | null'.
create(42);
Argument of type '42' is not assignable to parameter of type 'object | null'.
create("string");
Argument of type '"string"' is not assignable to parameter of type 'object | null'.
create(false);
Argument of type 'false' is not assignable to parameter of type 'object | null'.
Note the comment on line 4 saying Remember, undefined is a subtype of null.
If thats the case, why on the next line does it throw the error Argument of type 'undefined' is not assignable to parameter of type 'object | null'..
Why cant I assign a subtype to it's base type. Is there a typo. Thanks