-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapped.ts
More file actions
39 lines (27 loc) · 700 Bytes
/
mapped.ts
File metadata and controls
39 lines (27 loc) · 700 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
type FlexibleDogInfo = {
name: string
[key: string]: string | number
}
const doggi: FlexibleDogInfo = {
name: 'lilo',
age: 8
}
interface DogInfo {
name: string
age: number
}
type Options<Type> = {
[key in keyof Type]: boolean
}
type DogInfoOptions = Options<DogInfo>
// *----------------------------------------------------------
type Listeners<T> = {
[key in keyof T as `on${Capitalize<string & key>}Change`]?: (value: T[key]) => void
}
type DogInfoListener = Listeners<DogInfo>
function ListentoObject<T>(obj: T, listeners: Listeners<T>): void {
}
const lilo: DogInfo = { age: 15, name: 'rata' }
ListentoObject(lilo, {
onNameChange: (v: string) => { lilo.name = v }
})