Type alias RecursivePartial<T, TExclude>

RecursivePartial<T, TExclude>: {
    [P in keyof T]?: T[P] extends TExclude
        ? T[P]
        : RecursivePartial<T[P], TExclude>
}

TypeScript 類型,遞迴版的 Partial<T>, 如果成員的類型是 TExclude 則不遞迴

Type Parameters

  • T

    類型

  • TExclude = never

    要避免遞迴的類型

Example

type Foo = { geo: GeoPoint, label: { text: string; size: number } };
type A = Partial<Foo>
// type A = { geo?: GeoPoint, label?: { text: string; size: number } }
type B = RecursivePartial<Foo>
// type B = { geo?: {x?: number, y?: number, z?: number, Add?.....}, label?: { text?: string; size?: number } }
type C = RecursivePartial<Foo, GeoPoint>
// type C = { geo?: GeoPoint, label?: { text?: string; size?: number } }

Generated using TypeDoc