( def: array, operator: TupleExpressionOperator, min: number, max = min )
| 425 | export type UnparsedTupleOperator = show<keyof UnparsedTupleExpressionInput> |
| 426 | |
| 427 | export const assertTupleArity = ( |
| 428 | def: array, |
| 429 | operator: TupleExpressionOperator, |
| 430 | min: number, |
| 431 | max = min |
| 432 | ): void => { |
| 433 | if (def.length < min) |
| 434 | throwParseError(writeMissingRightOperandMessage(operator, "")) |
| 435 | if (def.length > max) { |
| 436 | throwParseError( |
| 437 | writeUnexpectedTupleElementsMessage( |
| 438 | operator, |
| 439 | min === max ? min : `${min} or ${max}`, |
| 440 | def.length |
| 441 | ) |
| 442 | ) |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | export const parseKeyOfTuple: IndexZeroParser<"keyof"> = (def, ctx) => { |
| 447 | assertTupleArity(def, "keyof", 2) |
no test coverage detected