From 8c69ef6b8d0f6dede1061d8f18b250ef9717d16b Mon Sep 17 00:00:00 2001 From: Yuuki-Sakura Date: Sun, 28 May 2023 11:37:09 +0800 Subject: [PATCH] lint: format code --- src/find-options/FindReturnType.ts | 94 +++++++++++++++++------------- 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/src/find-options/FindReturnType.ts b/src/find-options/FindReturnType.ts index f779f27df8..dbe9acf43e 100644 --- a/src/find-options/FindReturnType.ts +++ b/src/find-options/FindReturnType.ts @@ -16,28 +16,18 @@ type ExtractNil = Exclude> type ArrayType = Array | ExtractNil -export type FindReturnType< +type PickSelect< Entity extends ObjectLiteral, Select extends | FindOptionsSelect | FindOptionsSelectByString | undefined, - Relation extends - | FindOptionsRelations - | FindOptionsRelationByString - | undefined, -> = keyof Select extends never - ? keyof Relation extends never - ? Entity - : Entity & { - [R in Relation extends FindOptionsRelationByString - ? never - : TruthyKeys]: Relation extends FindOptionsRelations - ? Relation[R] extends FindOptionsRelations - ? FindReturnType - : Entity[R] - : Entity[R] - } +> = Select extends FindOptionsSelectByString + ? { + [R in Select extends FindOptionsSelectByString + ? Select[number] + : never]: Entity[R] + } : { [R in Select extends FindOptionsSelectByString ? never @@ -58,28 +48,50 @@ export type FindReturnType< ? FindReturnType : Entity[R] : Entity[R] - } & { - [R in Relation extends FindOptionsRelationByString - ? never - : TruthyKeys]: Exclude< - Entity[R], - undefined | null - > extends Array - ? U extends object - ? Relation[R] extends FindOptionsRelations - ? ArrayType< - FindReturnType, - Entity[R] - > - : ArrayType - : ArrayType - : Entity[R] extends object - ? Relation[R] extends FindOptionsRelations - ? FindReturnType - : Entity[R] - : Entity[R] - } & { - [R in Select extends FindOptionsSelectByString - ? Select[number] - : never]: Entity[R] } + +type PickRelations< + Entity extends ObjectLiteral, + Relation extends + | FindOptionsRelations + | FindOptionsRelationByString + | undefined, +> = { + [R in Relation extends FindOptionsRelationByString + ? never + : TruthyKeys]: Exclude< + Entity[R], + undefined | null + > extends Array + ? U extends object + ? Relation[R] extends FindOptionsRelations + ? ArrayType< + FindReturnType, + Entity[R] + > + : ArrayType + : ArrayType + : Entity[R] extends object + ? Relation[R] extends FindOptionsRelations + ? FindReturnType + : Entity[R] + : Entity[R] +} + +export type FindReturnType< + Entity extends ObjectLiteral, + Select extends + | FindOptionsSelect + | FindOptionsSelectByString + | undefined, + Relation extends + | FindOptionsRelations + | FindOptionsRelationByString + | undefined, +> = keyof Select extends never + ? keyof Relation extends never + ? Entity + : Entity & PickRelations + : keyof Relation extends never + ? PickSelect + : PickSelect & PickRelations