1
+ Syntactic Diagnostics for file '/tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts':
2
+
3
+
4
+ ==== /tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts (0 errors) ====
5
+
6
+ type ActionFunction<
7
+ TExpressionEvent extends { type: string },
8
+ out TEvent extends { type: string }
9
+ > = {
10
+ ({ event }: { event: TExpressionEvent }): void;
11
+ _out_TEvent?: TEvent;
12
+ };
13
+
14
+ interface MachineConfig<TEvent extends { type: string }> {
15
+ types: {
16
+ events: TEvent;
17
+ };
18
+ on: {
19
+ [K in TEvent["type"]]?: ActionFunction<
20
+ Extract<TEvent, { type: K }>,
21
+ TEvent
22
+ >;
23
+ };
24
+ }
25
+
26
+ declare function raise<
27
+ TExpressionEvent extends { type: string },
28
+ TEvent extends { type: string }
29
+ >(
30
+ resolve: ({ event }: { event: TExpressionEvent }) => TEvent
31
+ ): {
32
+ ({ event }: { event: TExpressionEvent }): void;
33
+ _out_TEvent?: TEvent;
34
+ };
35
+
36
+ declare function createMachine<TEvent extends { type: string }>(
37
+ config: MachineConfig<TEvent>
38
+ ): void;
39
+
40
+ createMachine({
41
+ types: {
42
+ events: {} as { type: "FOO" } | { type: "BAR" },
43
+ },
44
+ on: {
45
+ FOO: raise(({ event }) => {
46
+ return {
47
+ type: "BAR" as const,
48
+ };
49
+ }),
50
+ },
51
+ });
52
+
53
+ Semantic Diagnostics for file '/tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts':
54
+ /tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts(41,5): error TS2322: Type '{ ({ event }: { event: { type: "FOO"; }; }): void; _out_TEvent?: { type: "BARx"; } | undefined; }' is not assignable to type 'ActionFunction<{ type: "FOO"; }, { type: "FOO"; } | { type: "BAR"; }>'.
55
+ Types of property '_out_TEvent' are incompatible.
56
+ Type '{ type: "BARx"; } | undefined' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'.
57
+ Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'.
58
+ Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; }'.
59
+ Type '{ type: "BARx"; }' is not assignable to type '{ type: "BAR"; }'.
60
+ Types of property 'type' are incompatible.
61
+ Type '"BARx"' is not assignable to type '"BAR"'.
62
+
63
+
64
+ ==== /tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts (1 errors) ====
65
+
66
+ type ActionFunction<
67
+ TExpressionEvent extends { type: string },
68
+ out TEvent extends { type: string }
69
+ > = {
70
+ ({ event }: { event: TExpressionEvent }): void;
71
+ _out_TEvent?: TEvent;
72
+ };
73
+
74
+ interface MachineConfig<TEvent extends { type: string }> {
75
+ types: {
76
+ events: TEvent;
77
+ };
78
+ on: {
79
+ [K in TEvent["type"]]?: ActionFunction<
80
+ Extract<TEvent, { type: K }>,
81
+ TEvent
82
+ >;
83
+ };
84
+ }
85
+
86
+ declare function raise<
87
+ TExpressionEvent extends { type: string },
88
+ TEvent extends { type: string }
89
+ >(
90
+ resolve: ({ event }: { event: TExpressionEvent }) => TEvent
91
+ ): {
92
+ ({ event }: { event: TExpressionEvent }): void;
93
+ _out_TEvent?: TEvent;
94
+ };
95
+
96
+ declare function createMachine<TEvent extends { type: string }>(
97
+ config: MachineConfig<TEvent>
98
+ ): void;
99
+
100
+ createMachine({
101
+ types: {
102
+ events: {} as { type: "FOO" } | { type: "BAR" },
103
+ },
104
+ on: {
105
+ FOO: raise(({ event }) => {
106
+ ~~~
107
+ !!! error TS2322: Type '{ ({ event }: { event: { type: "FOO"; }; }): void; _out_TEvent?: { type: "BARx"; } | undefined; }' is not assignable to type 'ActionFunction<{ type: "FOO"; }, { type: "FOO"; } | { type: "BAR"; }>'.
108
+ !!! error TS2322: Types of property '_out_TEvent' are incompatible.
109
+ !!! error TS2322: Type '{ type: "BARx"; } | undefined' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'.
110
+ !!! error TS2322: Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'.
111
+ !!! error TS2322: Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; }'.
112
+ !!! error TS2322: Type '{ type: "BARx"; }' is not assignable to type '{ type: "BAR"; }'.
113
+ !!! error TS2322: Types of property 'type' are incompatible.
114
+ !!! error TS2322: Type '"BARx"' is not assignable to type '"BAR"'.
115
+ !!! related TS6500 /tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts:14:7: The expected type comes from property 'FOO' which is declared here on type '{ FOO?: ActionFunction<{ type: "FOO"; }, { type: "FOO"; } | { type: "BAR"; }> | undefined; BAR?: ActionFunction<{ type: "BAR"; }, { type: "FOO"; } | { type: "BAR"; }> | undefined; }'
116
+ return {
117
+ type: "BAR" as const,
118
+ };
119
+ }),
120
+ },
121
+ });
0 commit comments