(field: D)
| 396 | |
| 397 | /** @internal */ |
| 398 | export const discriminators = <D extends string>(field: D) => |
| 399 | < |
| 400 | R, |
| 401 | Ret, |
| 402 | P extends |
| 403 | & { |
| 404 | readonly [Tag in Types.Tags<D, R> & string]?: |
| 405 | | ((_: Extract<R, Record<D, Tag>>) => Ret) |
| 406 | | undefined |
| 407 | } |
| 408 | & { readonly [Tag in Exclude<keyof P, Types.Tags<D, R>>]: never } |
| 409 | >( |
| 410 | fields: P |
| 411 | ) => { |
| 412 | const predicate = makeWhen( |
| 413 | (arg: any) => arg != null && arg[field] in fields, |
| 414 | (data: any) => (fields as any)[data[field]](data) |
| 415 | ) |
| 416 | |
| 417 | return <I, F, A, Pr>( |
| 418 | self: Matcher<I, F, R, A, Pr, Ret> |
| 419 | ): Matcher< |
| 420 | I, |
| 421 | Types.AddWithout<F, Extract<R, Record<D, keyof P>>>, |
| 422 | Types.ApplyFilters<I, Types.AddWithout<F, Extract<R, Record<D, keyof P>>>>, |
| 423 | A | ReturnType<P[keyof P] & {}>, |
| 424 | Pr, |
| 425 | Ret |
| 426 | > => (self as any).add(predicate) |
| 427 | } |
| 428 | |
| 429 | /** @internal */ |
| 430 | export const discriminatorsExhaustive: <D extends string>( |
no test coverage detected