Generic TypeScript interface with mixed member types
问题 For several HTML forms, I want to configure inputs and deal with their values. My types have the following structure (you may copy it to TypeScript Playground http://www.typescriptlang.org/play to see it in action): interface InputConfig { readonly inputType: "text" | "password" | "list" readonly attributes?: ReadonlyArray<string> readonly cssClasses?: ReadonlyArray<string> } interface Inputs<T extends InputConfig | string | string[]> { readonly username: (T & InputConfig) | (T & string)