-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
67 lines (43 loc) · 878 Bytes
/
test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
interface Context {}
class Flavor<C extends Context> {
constructor(private readonly ctx: C) {}
}
type FlavorContext<C extends Context> = C & {
flavor: Flavor<C>
}
const useFlavor = <C extends FlavorContext<Context>>(ctx: C) => {
ctx.flavor = new Flavor(ctx)
}
class A<T> {
constructor() {
}
transform<V extends T>(): A<V> {
return new A<V>()
}
}
class B<T> {
c = B
constructor() {
}
static make<V>(s: string) {
return new B<V>()
}
transform<V extends T>() {
return this.c.make<V>('s')
}
}
class C<T> extends B<T> {
c = C
constructor() {
super()
}
static make<V>(s: string) {
return new C<V>()
}
transformNew<V extends T>() {
return this.c.make<V>('s')
}
}
const c = new C<{a: string}>()
const f = c.transform<{a: string, b: number}>()
const f2 = c.transformNew<{a: string, b: number}>()