main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
817 bytes
|
Line | |
---|
1 | import { Record } from './Record';
|
---|
2 | import { Key } from '../Any/Key';
|
---|
3 | import { IntersectOf } from '../Union/IntersectOf';
|
---|
4 | import { ComputeRaw } from '../Any/Compute';
|
---|
5 | /**
|
---|
6 | * @hidden
|
---|
7 | */
|
---|
8 | export declare type _Invert<O extends Record<Key, Key>> = ComputeRaw<IntersectOf<{
|
---|
9 | [K in keyof O]: Record<O[K], K>;
|
---|
10 | }[keyof O]>>;
|
---|
11 | /**
|
---|
12 | * Swaps the keys and values of an [[Object]] (if applicable)
|
---|
13 | * @param O
|
---|
14 | * @returns [[Object]]
|
---|
15 | * @example
|
---|
16 | * ```ts
|
---|
17 | * import {O} from 'ts-toolbelt'
|
---|
18 | *
|
---|
19 | * enum E {
|
---|
20 | * A = 'Av',
|
---|
21 | * B = 'Bv',
|
---|
22 | * C = 'Cv',
|
---|
23 | * D = 'Dv',
|
---|
24 | * X = 1
|
---|
25 | * }
|
---|
26 | *
|
---|
27 | * type O = {
|
---|
28 | * A: 'Av'
|
---|
29 | * B: 'Bv'
|
---|
30 | * C: 'Cv'
|
---|
31 | * D: 'Dv'
|
---|
32 | * X: 1
|
---|
33 | * }
|
---|
34 | *
|
---|
35 | * type test0 = O.Invert<typeof E>
|
---|
36 | * type test1 = O.Invert<O>
|
---|
37 | * ```
|
---|
38 | */
|
---|
39 | export declare type Invert<O extends Record<keyof O, Key>> = O extends unknown ? _Invert<O> : never;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.