“TypeScript Deep Partial” Ответ

Типовой рекурсивный частичный

type RecursivePartial<T> = {
  [P in keyof T]?:
    T[P] extends (infer U)[] ? RecursivePartial<U>[] :
    T[P] extends object ? RecursivePartial<T[P]> :
    T[P];
};
Combative Cardinal

Глубокий частичный типовой

//You can simply create a new type, say, DeepPartial, which basically references itself:
type DeepPartial<T> = {
    [P in keyof T]?: DeepPartial<T[P]>;
};

//Then, you can use it as such:
const foobar: DeepPartial<Foobar> = {
  foo: 1,
  bar: { baz: true }
};
MassimoMx

TypeScript Deep Partial

type DeepPartial<T> = {
    [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};
Stupid Scarab

Ответы похожие на “TypeScript Deep Partial”

Вопросы похожие на “TypeScript Deep Partial”

Больше похожих ответов на “TypeScript Deep Partial” по TypeScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования