Skip to content

Commit e0a1e0d

Browse files
committed
make the test case more realistic
1 parent 8a8b22e commit e0a1e0d

File tree

3 files changed

+72
-43
lines changed

3 files changed

+72
-43
lines changed

tests/baselines/reference/inferenceGenericNestedCallReturningConstructor.symbols

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,71 @@
11
//// [tests/cases/compiler/inferenceGenericNestedCallReturningConstructor.ts] ////
22

33
=== inferenceGenericNestedCallReturningConstructor.ts ===
4-
interface AssignObject<TContext> {
5-
>AssignObject : Symbol(AssignObject, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 0))
6-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 23))
4+
interface Action<TContext> {
5+
>Action : Symbol(Action, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 0))
6+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 17))
77

88
new (ctx: TContext): void;
99
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 1, 7))
10-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 23))
10+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 17))
11+
}
12+
13+
declare class AssignAction<TContext> {
14+
>AssignAction : Symbol(AssignAction, Decl(inferenceGenericNestedCallReturningConstructor.ts, 2, 1))
15+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 4, 27))
16+
17+
constructor(ctx: TContext);
18+
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 5, 14))
19+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 4, 27))
1120
}
1221

1322
declare function assign<TContext>(
14-
>assign : Symbol(assign, Decl(inferenceGenericNestedCallReturningConstructor.ts, 2, 1))
15-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 4, 24))
23+
>assign : Symbol(assign, Decl(inferenceGenericNestedCallReturningConstructor.ts, 6, 1))
24+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 24))
1625

1726
assigner: (ctx: TContext) => void
18-
>assigner : Symbol(assigner, Decl(inferenceGenericNestedCallReturningConstructor.ts, 4, 34))
19-
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 5, 13))
20-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 4, 24))
27+
>assigner : Symbol(assigner, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 34))
28+
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 9, 13))
29+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 24))
2130

22-
): AssignObject<TContext>;
23-
>AssignObject : Symbol(AssignObject, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 0))
24-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 4, 24))
31+
): {
32+
new (ctx: TContext): AssignAction<TContext>;
33+
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 11, 7))
34+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 24))
35+
>AssignAction : Symbol(AssignAction, Decl(inferenceGenericNestedCallReturningConstructor.ts, 2, 1))
36+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 24))
37+
}
2538

2639
declare function createMachine<TContext>(config: {
27-
>createMachine : Symbol(createMachine, Decl(inferenceGenericNestedCallReturningConstructor.ts, 6, 26))
28-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 31))
29-
>config : Symbol(config, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 41))
40+
>createMachine : Symbol(createMachine, Decl(inferenceGenericNestedCallReturningConstructor.ts, 12, 1))
41+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 14, 31))
42+
>config : Symbol(config, Decl(inferenceGenericNestedCallReturningConstructor.ts, 14, 41))
3043

3144
context: TContext;
32-
>context : Symbol(context, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 50))
33-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 31))
45+
>context : Symbol(context, Decl(inferenceGenericNestedCallReturningConstructor.ts, 14, 50))
46+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 14, 31))
3447

35-
entry: AssignObject<TContext>;
36-
>entry : Symbol(entry, Decl(inferenceGenericNestedCallReturningConstructor.ts, 9, 20))
37-
>AssignObject : Symbol(AssignObject, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 0))
38-
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 8, 31))
48+
entry: Action<TContext>;
49+
>entry : Symbol(entry, Decl(inferenceGenericNestedCallReturningConstructor.ts, 15, 20))
50+
>Action : Symbol(Action, Decl(inferenceGenericNestedCallReturningConstructor.ts, 0, 0))
51+
>TContext : Symbol(TContext, Decl(inferenceGenericNestedCallReturningConstructor.ts, 14, 31))
3952

4053
}): void;
4154

4255
createMachine({
43-
>createMachine : Symbol(createMachine, Decl(inferenceGenericNestedCallReturningConstructor.ts, 6, 26))
56+
>createMachine : Symbol(createMachine, Decl(inferenceGenericNestedCallReturningConstructor.ts, 12, 1))
4457

4558
context: { count: 0 },
46-
>context : Symbol(context, Decl(inferenceGenericNestedCallReturningConstructor.ts, 13, 15))
47-
>count : Symbol(count, Decl(inferenceGenericNestedCallReturningConstructor.ts, 14, 12))
59+
>context : Symbol(context, Decl(inferenceGenericNestedCallReturningConstructor.ts, 19, 15))
60+
>count : Symbol(count, Decl(inferenceGenericNestedCallReturningConstructor.ts, 20, 12))
4861

4962
entry: assign((ctx) => {
50-
>entry : Symbol(entry, Decl(inferenceGenericNestedCallReturningConstructor.ts, 14, 24))
51-
>assign : Symbol(assign, Decl(inferenceGenericNestedCallReturningConstructor.ts, 2, 1))
52-
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 15, 17))
63+
>entry : Symbol(entry, Decl(inferenceGenericNestedCallReturningConstructor.ts, 20, 24))
64+
>assign : Symbol(assign, Decl(inferenceGenericNestedCallReturningConstructor.ts, 6, 1))
65+
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 21, 17))
5366

5467
ctx // { count: number }
55-
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 15, 17))
68+
>ctx : Symbol(ctx, Decl(inferenceGenericNestedCallReturningConstructor.ts, 21, 17))
5669

5770
}),
5871
});

tests/baselines/reference/inferenceGenericNestedCallReturningConstructor.types

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
11
//// [tests/cases/compiler/inferenceGenericNestedCallReturningConstructor.ts] ////
22

33
=== inferenceGenericNestedCallReturningConstructor.ts ===
4-
interface AssignObject<TContext> {
4+
interface Action<TContext> {
55
new (ctx: TContext): void;
66
>ctx : TContext
77
}
88

9+
declare class AssignAction<TContext> {
10+
>AssignAction : AssignAction<TContext>
11+
12+
constructor(ctx: TContext);
13+
>ctx : TContext
14+
}
15+
916
declare function assign<TContext>(
10-
>assign : <TContext>(assigner: (ctx: TContext) => void) => AssignObject<TContext>
17+
>assign : <TContext>(assigner: (ctx: TContext) => void) => new (ctx: TContext) => AssignAction<TContext>
1118

1219
assigner: (ctx: TContext) => void
1320
>assigner : (ctx: TContext) => void
1421
>ctx : TContext
1522

16-
): AssignObject<TContext>;
23+
): {
24+
new (ctx: TContext): AssignAction<TContext>;
25+
>ctx : TContext
26+
}
1727

1828
declare function createMachine<TContext>(config: {
19-
>createMachine : <TContext>(config: { context: TContext; entry: AssignObject<TContext>;}) => void
20-
>config : { context: TContext; entry: AssignObject<TContext>; }
29+
>createMachine : <TContext>(config: { context: TContext; entry: Action<TContext>;}) => void
30+
>config : { context: TContext; entry: Action<TContext>; }
2131

2232
context: TContext;
2333
>context : TContext
2434

25-
entry: AssignObject<TContext>;
26-
>entry : AssignObject<TContext>
35+
entry: Action<TContext>;
36+
>entry : Action<TContext>
2737

2838
}): void;
2939

3040
createMachine({
3141
>createMachine({ context: { count: 0 }, entry: assign((ctx) => { ctx // { count: number } }),}) : void
32-
>createMachine : <TContext>(config: { context: TContext; entry: AssignObject<TContext>; }) => void
33-
>{ context: { count: 0 }, entry: assign((ctx) => { ctx // { count: number } }),} : { context: { count: number; }; entry: AssignObject<{ count: number; }>; }
42+
>createMachine : <TContext>(config: { context: TContext; entry: Action<TContext>; }) => void
43+
>{ context: { count: 0 }, entry: assign((ctx) => { ctx // { count: number } }),} : { context: { count: number; }; entry: new (ctx: { count: number; }) => AssignAction<{ count: number; }>; }
3444

3545
context: { count: 0 },
3646
>context : { count: number; }
@@ -39,9 +49,9 @@ createMachine({
3949
>0 : 0
4050

4151
entry: assign((ctx) => {
42-
>entry : AssignObject<{ count: number; }>
43-
>assign((ctx) => { ctx // { count: number } }) : AssignObject<{ count: number; }>
44-
>assign : <TContext>(assigner: (ctx: TContext) => void) => AssignObject<TContext>
52+
>entry : new (ctx: { count: number; }) => AssignAction<{ count: number; }>
53+
>assign((ctx) => { ctx // { count: number } }) : new (ctx: { count: number; }) => AssignAction<{ count: number; }>
54+
>assign : <TContext>(assigner: (ctx: TContext) => void) => new (ctx: TContext) => AssignAction<TContext>
4555
>(ctx) => { ctx // { count: number } } : (ctx: { count: number; }) => void
4656
>ctx : { count: number; }
4757

tests/cases/compiler/inferenceGenericNestedCallReturningConstructor.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
// @strict: true
22
// @noEmit: true
33

4-
interface AssignObject<TContext> {
4+
interface Action<TContext> {
55
new (ctx: TContext): void;
66
}
77

8+
declare class AssignAction<TContext> {
9+
constructor(ctx: TContext);
10+
}
11+
812
declare function assign<TContext>(
913
assigner: (ctx: TContext) => void
10-
): AssignObject<TContext>;
14+
): {
15+
new (ctx: TContext): AssignAction<TContext>;
16+
}
1117

1218
declare function createMachine<TContext>(config: {
1319
context: TContext;
14-
entry: AssignObject<TContext>;
20+
entry: Action<TContext>;
1521
}): void;
1622

1723
createMachine({

0 commit comments

Comments
 (0)