Skip to content

Commit 12a5fba

Browse files
committed
add extra test case
1 parent 0a0e499 commit 12a5fba

3 files changed

Lines changed: 358 additions & 0 deletions
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
//// [tests/cases/compiler/genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts] ////
2+
3+
=== genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts ===
4+
declare const EffectTypeId: unique symbol;
5+
>EffectTypeId : Symbol(EffectTypeId, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 0, 13))
6+
7+
interface Variance<out A, out E, out R> {
8+
>Variance : Symbol(Variance, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 0, 42))
9+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 2, 19))
10+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 2, 25))
11+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 2, 32))
12+
13+
readonly [EffectTypeId]: VarianceStruct<A, E, R>;
14+
>[EffectTypeId] : Symbol(Variance[EffectTypeId], Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 2, 41))
15+
>EffectTypeId : Symbol(EffectTypeId, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 0, 13))
16+
>VarianceStruct : Symbol(VarianceStruct, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 6, 36))
17+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 2, 19))
18+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 2, 25))
19+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 2, 32))
20+
}
21+
22+
type Covariant<A> = (_: never) => A;
23+
>Covariant : Symbol(Covariant, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 4, 1))
24+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 6, 15))
25+
>_ : Symbol(_, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 6, 21))
26+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 6, 15))
27+
28+
interface VarianceStruct<out A, out E, out R> {
29+
>VarianceStruct : Symbol(VarianceStruct, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 6, 36))
30+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 8, 25))
31+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 8, 31))
32+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 8, 38))
33+
34+
readonly _V: string;
35+
>_V : Symbol(VarianceStruct._V, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 8, 47))
36+
37+
readonly _A: Covariant<A>;
38+
>_A : Symbol(VarianceStruct._A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 9, 22))
39+
>Covariant : Symbol(Covariant, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 4, 1))
40+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 8, 25))
41+
42+
readonly _E: Covariant<E>;
43+
>_E : Symbol(VarianceStruct._E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 10, 28))
44+
>Covariant : Symbol(Covariant, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 4, 1))
45+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 8, 31))
46+
47+
readonly _R: Covariant<R>;
48+
>_R : Symbol(VarianceStruct._R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 11, 28))
49+
>Covariant : Symbol(Covariant, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 4, 1))
50+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 8, 38))
51+
}
52+
53+
interface Effect<out A, out E = never, out R = never>
54+
>Effect : Symbol(Effect, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 13, 1))
55+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 15, 17))
56+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 15, 23))
57+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 15, 38))
58+
59+
extends Variance<A, E, R> {}
60+
>Variance : Symbol(Variance, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 0, 42))
61+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 15, 17))
62+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 15, 23))
63+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 15, 38))
64+
65+
declare const succeed: <A>(value: A) => Effect<A>;
66+
>succeed : Symbol(succeed, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 13))
67+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 24))
68+
>value : Symbol(value, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 27))
69+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 24))
70+
>Effect : Symbol(Effect, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 13, 1))
71+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 24))
72+
73+
type F<X, Y> = Y extends { _type: infer Z }
74+
>F : Symbol(F, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 50))
75+
>X : Symbol(X, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 7))
76+
>Y : Symbol(Y, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 9))
77+
>Y : Symbol(Y, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 9))
78+
>_type : Symbol(_type, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 26))
79+
>Z : Symbol(Z, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 39))
80+
81+
? X extends Effect<infer A, infer E, infer R>
82+
>X : Symbol(X, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 7))
83+
>Effect : Symbol(Effect, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 13, 1))
84+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 21, 26))
85+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 21, 35))
86+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 21, 44))
87+
88+
? Effect<A, E, R | Z>
89+
>Effect : Symbol(Effect, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 13, 1))
90+
>A : Symbol(A, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 21, 26))
91+
>E : Symbol(E, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 21, 35))
92+
>R : Symbol(R, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 21, 44))
93+
>Z : Symbol(Z, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 39))
94+
95+
: X
96+
>X : Symbol(X, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 7))
97+
98+
: X;
99+
>X : Symbol(X, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 20, 7))
100+
101+
type ProxyMap<Service> = {
102+
>ProxyMap : Symbol(ProxyMap, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 24, 6))
103+
>Service : Symbol(Service, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 26, 14))
104+
105+
[K in keyof Service]: (Service & { _type: Service })[K];
106+
>K : Symbol(K, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 27, 3))
107+
>Service : Symbol(Service, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 26, 14))
108+
>Service : Symbol(Service, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 26, 14))
109+
>_type : Symbol(_type, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 27, 36))
110+
>Service : Symbol(Service, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 26, 14))
111+
>K : Symbol(K, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 27, 3))
112+
113+
};
114+
115+
declare const implement: <T>() => <I extends ReadonlyArray<any>, X>(
116+
>implement : Symbol(implement, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 13))
117+
>T : Symbol(T, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 26))
118+
>I : Symbol(I, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 35))
119+
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --))
120+
>X : Symbol(X, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 64))
121+
122+
x: (...i: I) => X,
123+
>x : Symbol(x, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 68))
124+
>i : Symbol(i, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 31, 6))
125+
>I : Symbol(I, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 35))
126+
>X : Symbol(X, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 64))
127+
128+
) => (...i: I) => F<X, T>;
129+
>i : Symbol(i, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 32, 6))
130+
>I : Symbol(I, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 35))
131+
>F : Symbol(F, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 50))
132+
>X : Symbol(X, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 64))
133+
>T : Symbol(T, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 26))
134+
135+
class XXX {
136+
>XXX : Symbol(XXX, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 32, 26))
137+
138+
log = implement<this>()(<N extends number>(n: N) => succeed(n));
139+
>log : Symbol(XXX.log, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 34, 11))
140+
>implement : Symbol(implement, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 30, 13))
141+
>N : Symbol(N, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 35, 27))
142+
>n : Symbol(n, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 35, 45))
143+
>N : Symbol(N, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 35, 27))
144+
>succeed : Symbol(succeed, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 18, 13))
145+
>n : Symbol(n, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 35, 45))
146+
}
147+
148+
export declare const inner: XXX;
149+
>inner : Symbol(inner, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 38, 20))
150+
>XXX : Symbol(XXX, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 32, 26))
151+
152+
export declare const outer: ProxyMap<XXX>;
153+
>outer : Symbol(outer, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 39, 20))
154+
>ProxyMap : Symbol(ProxyMap, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 24, 6))
155+
>XXX : Symbol(XXX, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 32, 26))
156+
157+
export const a = inner.log(100); // Effect<100, never, never>
158+
>a : Symbol(a, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 41, 12))
159+
>inner.log : Symbol(XXX.log, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 34, 11))
160+
>inner : Symbol(inner, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 38, 20))
161+
>log : Symbol(XXX.log, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 34, 11))
162+
163+
export const b = outer.log(100); // Effect<100, never, XXX>
164+
>b : Symbol(b, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 42, 12))
165+
>outer.log : Symbol(log, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 34, 11))
166+
>outer : Symbol(outer, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 39, 20))
167+
>log : Symbol(log, Decl(genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts, 34, 11))
168+
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
//// [tests/cases/compiler/genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts] ////
2+
3+
=== genericCallInferenceUsingThisTypeNoInvalidCacheReuseAfterMappedTypeApplication1.ts ===
4+
declare const EffectTypeId: unique symbol;
5+
>EffectTypeId : unique symbol
6+
> : ^^^^^^^^^^^^^
7+
8+
interface Variance<out A, out E, out R> {
9+
readonly [EffectTypeId]: VarianceStruct<A, E, R>;
10+
>[EffectTypeId] : VarianceStruct<A, E, R>
11+
> : ^^^^^^^^^^^^^^^^^^^^^^^
12+
>EffectTypeId : unique symbol
13+
> : ^^^^^^^^^^^^^
14+
}
15+
16+
type Covariant<A> = (_: never) => A;
17+
>Covariant : Covariant<A>
18+
> : ^^^^^^^^^^^^
19+
>_ : never
20+
> : ^^^^^
21+
22+
interface VarianceStruct<out A, out E, out R> {
23+
readonly _V: string;
24+
>_V : string
25+
> : ^^^^^^
26+
27+
readonly _A: Covariant<A>;
28+
>_A : Covariant<A>
29+
> : ^^^^^^^^^^^^
30+
31+
readonly _E: Covariant<E>;
32+
>_E : Covariant<E>
33+
> : ^^^^^^^^^^^^
34+
35+
readonly _R: Covariant<R>;
36+
>_R : Covariant<R>
37+
> : ^^^^^^^^^^^^
38+
}
39+
40+
interface Effect<out A, out E = never, out R = never>
41+
extends Variance<A, E, R> {}
42+
43+
declare const succeed: <A>(value: A) => Effect<A>;
44+
>succeed : <A>(value: A) => Effect<A>
45+
> : ^ ^^ ^^ ^^^^^
46+
>value : A
47+
> : ^
48+
49+
type F<X, Y> = Y extends { _type: infer Z }
50+
>F : F<X, Y>
51+
> : ^^^^^^^
52+
>_type : Z
53+
> : ^
54+
55+
? X extends Effect<infer A, infer E, infer R>
56+
? Effect<A, E, R | Z>
57+
: X
58+
: X;
59+
60+
type ProxyMap<Service> = {
61+
>ProxyMap : ProxyMap<Service>
62+
> : ^^^^^^^^^^^^^^^^^
63+
64+
[K in keyof Service]: (Service & { _type: Service })[K];
65+
>_type : Service
66+
> : ^^^^^^^
67+
68+
};
69+
70+
declare const implement: <T>() => <I extends ReadonlyArray<any>, X>(
71+
>implement : <T>() => <I extends ReadonlyArray<any>, X>(x: (...i: I) => X) => (...i: I) => F<X, T>
72+
> : ^ ^^^^^^^
73+
74+
x: (...i: I) => X,
75+
>x : (...i: I) => X
76+
> : ^^^^ ^^ ^^^^^
77+
>i : I
78+
> : ^
79+
80+
) => (...i: I) => F<X, T>;
81+
>i : I
82+
> : ^
83+
84+
class XXX {
85+
>XXX : XXX
86+
> : ^^^
87+
88+
log = implement<this>()(<N extends number>(n: N) => succeed(n));
89+
>log : <N extends number>(n: N) => F<Effect<N, never, never>, this>
90+
> : ^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91+
>implement<this>()(<N extends number>(n: N) => succeed(n)) : <N extends number>(n: N) => F<Effect<N, never, never>, this>
92+
> : ^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93+
>implement<this>() : <I extends ReadonlyArray<any>, X>(x: (...i: I) => X) => (...i: I) => F<X, this>
94+
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
95+
>implement : <T>() => <I extends ReadonlyArray<any>, X>(x: (...i: I) => X) => (...i: I) => F<X, T>
96+
> : ^ ^^^^^^^
97+
><N extends number>(n: N) => succeed(n) : <N extends number>(n: N) => Effect<N, never, never>
98+
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99+
>n : N
100+
> : ^
101+
>succeed(n) : Effect<N, never, never>
102+
> : ^^^^^^^^^^^^^^^^^^^^^^^
103+
>succeed : <A>(value: A) => Effect<A>
104+
> : ^ ^^ ^^ ^^^^^
105+
>n : N
106+
> : ^
107+
}
108+
109+
export declare const inner: XXX;
110+
>inner : XXX
111+
> : ^^^
112+
113+
export declare const outer: ProxyMap<XXX>;
114+
>outer : ProxyMap<XXX>
115+
> : ^^^^^^^^^^^^^
116+
117+
export const a = inner.log(100); // Effect<100, never, never>
118+
>a : Effect<100, never, never>
119+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
120+
>inner.log(100) : Effect<100, never, never>
121+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
122+
>inner.log : <N extends number>(n: N) => Effect<N, never, never>
123+
> : ^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124+
>inner : XXX
125+
> : ^^^
126+
>log : <N extends number>(n: N) => Effect<N, never, never>
127+
> : ^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
128+
>100 : 100
129+
> : ^^^
130+
131+
export const b = outer.log(100); // Effect<100, never, XXX>
132+
>b : Effect<100, never, XXX>
133+
> : ^^^^^^^^^^^^^^^^^^^^^^^
134+
>outer.log(100) : Effect<100, never, XXX>
135+
> : ^^^^^^^^^^^^^^^^^^^^^^^
136+
>outer.log : <N extends number>(n: N) => Effect<N, never, XXX>
137+
> : ^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138+
>outer : ProxyMap<XXX>
139+
> : ^^^^^^^^^^^^^
140+
>log : <N extends number>(n: N) => Effect<N, never, XXX>
141+
> : ^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
142+
>100 : 100
143+
> : ^^^
144+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
declare const EffectTypeId: unique symbol;
5+
6+
interface Variance<out A, out E, out R> {
7+
readonly [EffectTypeId]: VarianceStruct<A, E, R>;
8+
}
9+
10+
type Covariant<A> = (_: never) => A;
11+
12+
interface VarianceStruct<out A, out E, out R> {
13+
readonly _V: string;
14+
readonly _A: Covariant<A>;
15+
readonly _E: Covariant<E>;
16+
readonly _R: Covariant<R>;
17+
}
18+
19+
interface Effect<out A, out E = never, out R = never>
20+
extends Variance<A, E, R> {}
21+
22+
declare const succeed: <A>(value: A) => Effect<A>;
23+
24+
type F<X, Y> = Y extends { _type: infer Z }
25+
? X extends Effect<infer A, infer E, infer R>
26+
? Effect<A, E, R | Z>
27+
: X
28+
: X;
29+
30+
type ProxyMap<Service> = {
31+
[K in keyof Service]: (Service & { _type: Service })[K];
32+
};
33+
34+
declare const implement: <T>() => <I extends ReadonlyArray<any>, X>(
35+
x: (...i: I) => X,
36+
) => (...i: I) => F<X, T>;
37+
38+
class XXX {
39+
log = implement<this>()(<N extends number>(n: N) => succeed(n));
40+
}
41+
42+
export declare const inner: XXX;
43+
export declare const outer: ProxyMap<XXX>;
44+
45+
export const a = inner.log(100); // Effect<100, never, never>
46+
export const b = outer.log(100); // Effect<100, never, XXX>

0 commit comments

Comments
 (0)