mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
[next] Fix lookup and recursive types (#2472)
* fix: bug in lookup not checking object properly before accessing * fix: Recursive types not handling optional arrays
This commit is contained in:
@@ -36,7 +36,7 @@ const createProxy = <T = any>(
|
||||
return prop in recordSource;
|
||||
},
|
||||
get(_, prop) {
|
||||
if (prop in recordSource && (recordSource as any)[prop].__ref) {
|
||||
if ((recordSource as any)[prop] && (recordSource as any)[prop].__ref) {
|
||||
return lookup(environment, (recordSource as any)[prop].__ref);
|
||||
}
|
||||
return (recordSource as any)[prop];
|
||||
|
||||
@@ -8,16 +8,16 @@ import { DeepPartial } from "coral-framework/types";
|
||||
export type Callbackify<T> = T extends object
|
||||
?
|
||||
| {
|
||||
[P in keyof T]: T[P] extends Array<infer U>
|
||||
[P in keyof T]: T[P] extends (Array<infer U> | undefined)
|
||||
? Array<Callbackify<U>>
|
||||
: T[P] extends ReadonlyArray<infer V>
|
||||
: T[P] extends (ReadonlyArray<infer V> | undefined)
|
||||
? ReadonlyArray<Callbackify<V>>
|
||||
: Callbackify<T[P]>
|
||||
}
|
||||
| (() => {
|
||||
[P in keyof T]: T[P] extends Array<infer U>
|
||||
[P in keyof T]: T[P] extends (Array<infer U> | undefined)
|
||||
? Array<Callbackify<U>>
|
||||
: T[P] extends ReadonlyArray<infer V>
|
||||
: T[P] extends (ReadonlyArray<infer V> | undefined)
|
||||
? ReadonlyArray<Callbackify<V>>
|
||||
: Callbackify<T[P]>
|
||||
})
|
||||
@@ -28,9 +28,9 @@ export type Callbackify<T> = T extends object
|
||||
*/
|
||||
export type WithTypename<T> = T extends object
|
||||
? {
|
||||
[P in keyof T]: T[P] extends Array<infer U>
|
||||
[P in keyof T]: T[P] extends (Array<infer U> | undefined)
|
||||
? Array<WithTypename<U>>
|
||||
: T[P] extends ReadonlyArray<infer V>
|
||||
: T[P] extends (ReadonlyArray<infer V> | undefined)
|
||||
? ReadonlyArray<WithTypename<V>>
|
||||
: WithTypename<T[P]>
|
||||
} & { __typename?: string }
|
||||
|
||||
@@ -24,9 +24,9 @@ export type Nullable<T> = { [P in keyof T]: T[P] | null };
|
||||
|
||||
export type DeepNullable<T> = T extends object
|
||||
? {
|
||||
[P in keyof T]: T[P] extends Array<infer U>
|
||||
[P in keyof T]: T[P] extends (Array<infer U> | undefined)
|
||||
? Array<DeepNullable<U>>
|
||||
: T[P] extends ReadonlyArray<infer V>
|
||||
: T[P] extends (ReadonlyArray<infer V> | undefined)
|
||||
? ReadonlyArray<DeepNullable<V>>
|
||||
: DeepNullable<T[P]>
|
||||
}
|
||||
@@ -37,9 +37,9 @@ export type DeepNullable<T> = T extends object
|
||||
*/
|
||||
export type DeepPartial<T> = T extends object
|
||||
? {
|
||||
[P in keyof T]?: T[P] extends Array<infer U>
|
||||
[P in keyof T]?: T[P] extends (Array<infer U> | undefined)
|
||||
? Array<DeepPartial<U>>
|
||||
: T[P] extends ReadonlyArray<infer V>
|
||||
: T[P] extends (ReadonlyArray<infer V> | undefined)
|
||||
? ReadonlyArray<DeepPartial<V>>
|
||||
: DeepPartial<T[P]>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user