Why does Typescript allow for subtyping?
问题 According to docs, "Type compatibility in TypeScript is based on structural subtyping". So this is possible: type Person: { name: string; } const developer = { name: 'Joe', language: 'Typescript', } // this is ok because Person is a subtype of typeof developer const otherDeveloper: Person = developer; // who writes code like that?! This has many consequences, one of many is that you lose type information when using Object.keys: // "keys" type is array of strings not `name` literal as this