Skip to content

Commit db99a2d

Browse files
committed
chore: restrict array methods on DataErrorTuple
This improves: - Strengthens type safety by preventing unintended array operations. See: https://github.com/microsoft/TypeScript/issues/xyz for more context.
1 parent 9b4eb3e commit db99a2d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
type Branded<T> = T & { __tryCatchTupleResult: never };
2+
type DisableArrayMethods<T> = T & {
3+
[K in Exclude<keyof Array<any>, "length" | symbol>]: never;
4+
};
25

36
type DataErrorTuple<T, E> = Branded<
4-
[data: T, error: E] & never[]
7+
DisableArrayMethods<[data: T, error: E] & never[]>
58
>;
69

710
type Success<T> = DataErrorTuple<T, null>;

0 commit comments

Comments
 (0)