import {type OneOrMore} from '@myparcel/ts-utils'; export const validateId = , A extends boolean = false>( id?: O, canBeArray?: A, ): A extends true ? NonNullable : string => { if (!id) { throw new Error('no id provided'); } if (Array.isArray(id) && canBeArray !== true) { throw new Error('id cannot be an array'); } return id as A extends true ? NonNullable : string; };