SlimTim10@programming.dev to TypeScript@programming.dev • 11 months agoTypeScript's Hidden Feature: Subtypesimagemessage-square2 fedilinkarrow-up15
arrow-up15imageTypeScript's Hidden Feature: SubtypesSlimTim10@programming.dev to TypeScript@programming.dev • 11 months agomessage-square2 Commentsfedilink
minus-squaretowerful@programming.devhexbear2·11 months agoI presume the details of this post got lost somewhere? let x = () => ({ name: "Alice" }); let y = () => ({ name: "Alice", location: "Seattle" }); x = y; // OK y = x; // Error, because x() lacks a location property https://www.typescriptlang.org/docs/handbook/type-compatibility.html There doesn't seem to be an article directly on subtypes linkfedilink
I presume the details of this post got lost somewhere?
let x = () => ({ name: "Alice" }); let y = () => ({ name: "Alice", location: "Seattle" }); x = y; // OK y = x; // Error, because x() lacks a location property
https://www.typescriptlang.org/docs/handbook/type-compatibility.html
There doesn't seem to be an article directly on subtypes