UNPKG

695 BTypeScriptView Raw
1import { Key } from './Key';
2import { List } from '../List/List';
3/**
4 * Get in `O` the type of a field of key `K`
5 * @param O to extract from
6 * @param K to extract at
7 * @returns [[Any]]
8 * @example
9 * ```ts
10 * import {O} from 'ts-toolbelt'
11 *
12 * type User = {
13 * info: {
14 * name: string
15 * age: number
16 * payment: {}
17 * }
18 * id: number
19 * }
20 *
21 * type test0 = O.At<User, 'id'> // number
22 * ```
23 */
24export declare type At<A extends any, K extends Key> = A extends List ? number extends A['length'] ? K extends number | `${number}` ? A[never] | undefined : undefined : K extends keyof A ? A[K] : undefined : unknown extends A ? unknown : K extends keyof A ? A[K] : undefined;