diff --git a/src/Lazy/pipeLazy.ts b/src/Lazy/pipeLazy.ts index f551eee9..7a430c22 100644 --- a/src/Lazy/pipeLazy.ts +++ b/src/Lazy/pipeLazy.ts @@ -41,8 +41,6 @@ import type ReturnPipeType from "../types/ReturnPipeType"; * see {@link https://fxts.dev/docs/toAsync | toAsync}, * {@link https://fxts.dev/docs/map | map}, {@link https://fxts.dev/docs/filter | filter} */ -// eslint-disable-next-line -// @ts-ignore // prettier-ignore function pipeLazy( f1: (a: Awaited) => R diff --git a/src/types/ReturnPipeType.ts b/src/types/ReturnPipeType.ts index 8abd7399..0613bc10 100644 --- a/src/types/ReturnPipeType.ts +++ b/src/types/ReturnPipeType.ts @@ -1,5 +1,5 @@ import type Awaited from "./Awaited"; -import type { TuplifyUnion } from "./ExcludeObject"; +import type Equals from "./Equals"; import type Head from "./Head"; import type Tail from "./Tail"; @@ -13,7 +13,7 @@ type HasPromise = Head extends never type PossiblyHasPromise = Head extends never ? false - : HasPromise>> extends true + : Equals, Head | Promise>>> extends 1 ? true : T["length"] extends 0 ? false @@ -27,7 +27,7 @@ type PipeLast = T["length"] extends 0 ? never : PipeLast>; -type ReturnPipeType< +type _ReturnPipeType< T extends any[], R = Awaited>, > = HasPromise extends true @@ -36,4 +36,11 @@ type ReturnPipeType< ? Promise | R : R; +type ReturnPipeType< + T extends any[], + R = Awaited>, +> = _ReturnPipeType extends Promise + ? never + : _ReturnPipeType; + export default ReturnPipeType; diff --git a/type-check/pipe.test.ts b/type-check/pipe.test.ts index 3ff210de..59a5934e 100644 --- a/type-check/pipe.test.ts +++ b/type-check/pipe.test.ts @@ -73,6 +73,77 @@ const res17 = pipe( () => 2, ); +const Code = { + None: "NONE", + _00: "00", + _11: "11", + _13: "13", + _15: "15", + _17: "17", + _19: "19", + _21: "21", + _23: "23", + _25: "25", + _27: "27", + _29: "29", + _32: "32", + _34: "34", + _41: "41", + _43: "43", + _46: "46", + _52: "52", + _54: "54", + _56: "56", + _58: "58", + _62: "62", + _64: "64", + _66: "66", + _68: "68", + _72: "72", + _81: "81", + _83: "83", + _85: "85", + _96: "96", + _10: "10", + _12: "12", + _14: "14", + _16: "16", + _18: "18", + _20: "20", + _22: "22", + _24: "24", + _26: "26", + _28: "28", + _31: "31", + _33: "33", + _36: "36", + _42: "42", + _44: "44", + _51: "51", + _53: "53", + _55: "55", + _57: "57", + _61: "61", + _63: "63", + _65: "65", + _67: "67", + _71: "71", + _73: "73", + _74: "74", + _75: "75", + _76: "76", + _82: "82", + _84: "84", + _95: "95", +} as const; + +type Code = (typeof Code)[keyof typeof Code]; +const res18 = pipe({ code: Code.None }, (_: { code: Code }): Code => Code.None); +const res19 = pipe( + { code: Code.None }, + async (_: { code: Code }): Promise => Code.None, +); + checks([ check(), check(), @@ -91,4 +162,6 @@ checks([ check, Test.Pass>(), check(), check, Test.Pass>(), + check(), + check, Test.Pass>(), ]);