Skip to content

Commit 7dfe927

Browse files
committed
refactor: extract DataErrorTuple to type alias
1 parent 9ed0ab0 commit 7dfe927

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/try-catch-tuple/src/tryCatch.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
type Branded<T> = T & { __tryCatchTupleResult: any };
2-
type Success<T> = Branded<[data: T, error: null]>;
3-
type Failure<E extends Error> = Branded<[data: null, error: E | Error]>;
2+
3+
type DataErrorTuple<T, E> = Branded<
4+
[data: T, error: E]
5+
>;
6+
7+
type Success<T> = DataErrorTuple<T, null>;
8+
type Failure<E extends Error> = DataErrorTuple<null, E | Error>;
49
type Result<T, E extends Error> = Success<T> | Failure<E>;
510

611
type TryCatchResult<T, E extends Error> = T extends Promise<infer U>

0 commit comments

Comments
 (0)