Typescript: Partial<MyType> with sub-properties to optional
问题 Is it possible, in typescript, to let a method accept Partial<Something> , in a way that Something 's sub-properties are all set to optional too? export interface ISomething { user: IUser; } export interface IUser { id: number; name: string; } export const myMethod = (something: Partial<ISomething>): void => {}; myMethod({ user: { id: 1, name: "" } }); //this works myMethod({ user: { id: 1 } }); //this doesn't (but I want this to work too) many thanks ;) 回答1: You are essentially looking for