-
-
Notifications
You must be signed in to change notification settings - Fork 504
/
camel-cased-properties-deep.ts
49 lines (42 loc) · 1.11 KB
/
camel-cased-properties-deep.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
46
47
48
49
import {expectTypeOf} from 'expect-type';
import type {CamelCasedPropertiesDeep} from '../index';
declare const foo: CamelCasedPropertiesDeep<{A: {B: number; C: Array<{D: string}>}}>;
expectTypeOf(foo).toEqualTypeOf<{a: {b: number; c: Array<{d: string}>}}>();
declare const fooBar: CamelCasedPropertiesDeep<() => {a: string}>;
expectTypeOf(fooBar).toEqualTypeOf<() => {a: string}>();
declare const bar: CamelCasedPropertiesDeep<Set<{fooBar: string}>>;
expectTypeOf(bar).toEqualTypeOf<Set<{fooBar: string}>>();
// Verify example
type User = {
UserId: number;
UserName: string;
Date: Date;
RegExp: RegExp;
};
type UserWithFriends = {
UserInfo: User;
UserFriends: User[];
};
const result: CamelCasedPropertiesDeep<UserWithFriends> = {
userInfo: {
userId: 1,
userName: 'Tom',
date: new Date(),
regExp: new RegExp(/.*/),
},
userFriends: [
{
userId: 2,
userName: 'Jerry',
date: new Date(),
regExp: new RegExp(/.*/),
},
{
userId: 3,
userName: 'Spike',
date: new Date(),
regExp: new RegExp(/.*/),
},
],
};
expectTypeOf(result).toEqualTypeOf<CamelCasedPropertiesDeep<UserWithFriends>>();