Proper IntelliSense for function that takes and returns heterogeneous dictionary (TypeScript)
问题 I am trying to write a TypeScript type definition for a function that receives and returns heterogeneous types, but am struggling to get the compiler to output the right types. I am hoping someone well-versed in this could help. Suppose I have two classes, a Zebra and a Dog, defined as follows: declare class Zebra { constructor(id: number); getDescription(): { "type": string; "height": number; } } declare class Dog { constructor(id: number); getDescription(): { "type": string; "tailWagSpeed":