From 6747f5988356ab6ffd3c9bd1007ac79e98249fa3 Mon Sep 17 00:00:00 2001 From: tamaina <tamaina@hotmail.co.jp> Date: Sat, 25 Feb 2023 11:08:27 +0000 Subject: [PATCH] Revert "RequiredProp" This reverts commit 74693900119a590263106fa3adefd008d69ce80c. --- packages/backend/src/misc/schema.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/misc/schema.ts b/packages/backend/src/misc/schema.ts index 7630da893434..6a0802f8a408 100644 --- a/packages/backend/src/misc/schema.ts +++ b/packages/backend/src/misc/schema.ts @@ -116,10 +116,10 @@ export type Obj = Record<string, Schema>; // https://github.com/misskey-dev/misskey/issues/8535 // To avoid excessive stack depth error, // deceive TypeScript with UnionToIntersection (or more precisely, `infer` expression within it). -export type ObjType<s extends Obj, RequiredProp extends keyof s> = +export type ObjType<s extends Obj, RequiredProps extends ReadonlyArray<keyof s>> = UnionToIntersection< { -readonly [R in RequiredPropertyNames<s>]-?: SchemaType<s[R]> } & - { -readonly [R in RequiredProp]-?: SchemaType<s[R]> } & + { -readonly [R in RequiredProps[number]]-?: SchemaType<s[R]> } & { -readonly [P in keyof s]?: SchemaType<s[P]> } >; @@ -137,16 +137,16 @@ type PartialIntersection<T> = Partial<UnionToIntersection<T>>; // To get union, we use `Foo extends any ? Hoge<Foo> : never` type UnionSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? SchemaType<X> : never; //type UnionObjectSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? ObjectSchemaType<X> : never; -type UnionObjType<s extends Obj, a extends readonly any[], X extends ReadonlyArray<keyof s> = a[number]> = X extends any ? ObjType<s, X[number]> : never; +type UnionObjType<s extends Obj, a extends readonly any[], X extends ReadonlyArray<keyof s> = a[number]> = X extends any ? ObjType<s, X> : never; type ArrayUnion<T> = T extends any ? Array<T> : never; type ObjectSchemaTypeDef<p extends Schema> = p['ref'] extends keyof typeof refs ? Packed<p['ref']> : p['properties'] extends NonNullable<Obj> ? p['anyOf'] extends ReadonlyArray<Schema> ? p['anyOf'][number]['required'] extends ReadonlyArray<keyof p['properties']> ? - UnionObjType<p['properties'], NonNullable<p['anyOf'][number]['required']>> & ObjType<p['properties'], NonNullable<p['required']>[number]> + UnionObjType<p['properties'], NonNullable<p['anyOf'][number]['required']>> & ObjType<p['properties'], NonNullable<p['required']>> : never - : ObjType<p['properties'], NonNullable<p['required']>[number]> + : ObjType<p['properties'], NonNullable<p['required']>> : p['anyOf'] extends ReadonlyArray<Schema> ? never : // see CONTRIBUTING.md p['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<p['allOf']>> :