Skip to content

Commit c46003b

Browse files
committed
📝 Add note about design limitation of isTupleOf
1 parent a03dda9 commit c46003b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

is.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export type TupleOf<T extends readonly Predicate<unknown>[]> = {
5959
* const _: [number, string, boolean] = a;
6060
* }
6161
* ```
62+
*
63+
* Note that `predTup` must be `readonly` (`as const`) to infer the type of `a` correctly.
64+
* TypeScript won't argues if `predTup` is not `readonly` because of its design limitation.
65+
* https://github.com/microsoft/TypeScript/issues/34274#issuecomment-541691353
6266
*/
6367
export function isTupleOf<T extends readonly Predicate<unknown>[]>(
6468
predTup: T,

0 commit comments

Comments
 (0)