recursive-partial.ts
· 454 B · TypeScript
Ham
/**
* ... then taken from
* https://github.com/Noah2610/sync-tracker/blob/develop/lib/util/recursive-partial.ts
*/
/**
* Taken from Tone.js, which itself was taken from here:
* https://stackoverflow.com/a/51365037
*/
type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U>
? Array<RecursivePartial<U>>
: T[P] extends object
? RecursivePartial<T[P]>
: T[P];
};
export default RecursivePartial;
| 1 | /** |
| 2 | * ... then taken from |
| 3 | * https://github.com/Noah2610/sync-tracker/blob/develop/lib/util/recursive-partial.ts |
| 4 | */ |
| 5 | |
| 6 | /** |
| 7 | * Taken from Tone.js, which itself was taken from here: |
| 8 | * https://stackoverflow.com/a/51365037 |
| 9 | */ |
| 10 | type RecursivePartial<T> = { |
| 11 | [P in keyof T]?: T[P] extends Array<infer U> |
| 12 | ? Array<RecursivePartial<U>> |
| 13 | : T[P] extends object |
| 14 | ? RecursivePartial<T[P]> |
| 15 | : T[P]; |
| 16 | }; |
| 17 | |
| 18 | export default RecursivePartial; |
recursivePartial.ts
· 298 B · TypeScript
Ham
/**
* https://github.com/Noah2610/i3-color-theme-editor/blob/master/src/util/recursivePartial.ts
*/
export type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
? RecursivePartial<U>[]
: T[P] extends object
? RecursivePartial<T[P]>
: T[P];
};
| 1 | /** |
| 2 | * https://github.com/Noah2610/i3-color-theme-editor/blob/master/src/util/recursivePartial.ts |
| 3 | */ |
| 4 | |
| 5 | export type RecursivePartial<T> = { |
| 6 | [P in keyof T]?: T[P] extends (infer U)[] |
| 7 | ? RecursivePartial<U>[] |
| 8 | : T[P] extends object |
| 9 | ? RecursivePartial<T[P]> |
| 10 | : T[P]; |
| 11 | }; |