forked from sindresorhus/type-fest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deep-flatten-objects.ts
45 lines (40 loc) · 1.14 KB
/
deep-flatten-objects.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {expectAssignable} from 'tsd';
import type {DeepFlattenRecord} from '../index';
type Test1 = {
arrayKey: string[];
objectKey: {
nestedTwoArrayKey: string[];
nestedTwoObjectKey?: {
nestedThreeNumberKey: number;
};
nestedTwoStringKey: string;
nestedTwoFunctionKey: () => void;
};
stringKey: string;
numberKey: number;
functionKey: () => void;
};
type ExpectedTest1Cascade = {
arrayKey: string[];
nestedTwoArrayKey: string[];
nestedThreeNumberKey?: number;
nestedTwoStringKey: string;
nestedTwoFunctionKey: () => void;
stringKey: string;
numberKey: number;
functionKey: () => void;
};
type ExpectedTest1NoCascade = {
arrayKey: string[];
nestedTwoArrayKey: string[];
nestedThreeNumberKey: number;
nestedTwoStringKey: string;
nestedTwoFunctionKey: () => void;
stringKey: string;
numberKey: number;
functionKey: () => void;
};
declare const actualValueCascadeOptionality: ExpectedTest1Cascade;
declare const actualValueNoCascade: ExpectedTest1NoCascade;
expectAssignable<DeepFlattenRecord<Test1>>(actualValueCascadeOptionality);
expectAssignable<DeepFlattenRecord<Test1, {cascadeOptionality: false}>>(actualValueNoCascade);