-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathsimplify-deep.ts
More file actions
45 lines (38 loc) · 984 Bytes
/
simplify-deep.ts
File metadata and controls
45 lines (38 loc) · 984 Bytes
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 {expectType} from 'tsd';
import type {SimplifyDeep} from '../index.d.ts';
type Properties1 = {
height: number;
position: {
top: number;
bottom: number;
};
};
type Properties2 = {
width: number;
position: {
left: number;
right: number;
};
};
// Flatten the type output to improve type hints shown in editors.
declare const flattenProperties: {
height: number;
width: number;
position: {
top: number;
bottom: number;
left: number;
right: number;
};
};
expectType<SimplifyDeep<Properties1 & Properties2>>(flattenProperties);
// Array
declare function testArraySimplification(arg: {foo: Array<{[x: string]: string}>}): void;
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface BarBaz {
bar: string;
baz: string;
}
// This would fail if `SimplifyDeep` did not simplify arrays,
// because interfaces being open are not compatible with index signatures.
testArraySimplification({} as SimplifyDeep<{foo: BarBaz[]}>);