( record: Record<string, unknown>, key: string, values: T, )
| 431 | } |
| 432 | |
| 433 | export function optionalEnum<const T extends readonly string[]>( |
| 434 | record: Record<string, unknown>, |
| 435 | key: string, |
| 436 | values: T, |
| 437 | ): T[number] | undefined { |
| 438 | const value = record[key]; |
| 439 | if (value === undefined) return undefined; |
| 440 | if (typeof value !== 'string' || !values.includes(value)) { |
| 441 | throw new Error(`Expected ${key} to be one of: ${values.join(', ')}.`); |
| 442 | } |
| 443 | return value; |
| 444 | } |
| 445 | |
| 446 | export function commonToClientOptions( |
| 447 | input: CommonCommandInput, |
no outgoing calls
no test coverage detected
searching dependent graphs…