interface Serializable { serialize(): string }
function isSerializable(x: unknown): x is Serializable {
return typeof x === 'object' && x !== null &&
typeof (x as any).serialize === 'function'
}TypeScript's structural typing means any object with the right methods satisfies an interface at runtime.
TypeScript uses structural typing β but at runtime, you must check the shape manually.
Challenge: Implement isConformingShape(value) returning true if value has a name property of type string.
isConformingShape({ name: 'Alice' }) // β true
isConformingShape({ name: 42 }) // β false