Skip to content

Commit 3cd5ff5

Browse files
authored
Merge pull request #22 from lambdalisue/add-note-about-design-limitation
📝 Add note about design limitation of `isTupleOf`
2 parents a03dda9 + c46003b commit 3cd5ff5

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)