@@ -4,14 +4,17 @@ import * as React from "react";
4
4
5
5
import {
6
6
ReComponent ,
7
-
8
7
Update ,
9
8
NoUpdate ,
10
9
SideEffects ,
11
10
UpdateWithSideEffects
12
11
} from "../../" ;
13
12
14
- type Action = { | type : "A" | } | { | type : "B" | } | { | type : "C" | } | { | type : "D" | }
13
+ type Action =
14
+ | { | type : "A" | }
15
+ | { | type : "B" | }
16
+ | { | type : "C" | }
17
+ | { | type : "D" | } ;
15
18
16
19
class StateMismatch extends ReComponent < { } , { count : number } , Action > {
17
20
// $ExpectError
@@ -54,7 +57,6 @@ class UpdateTypes extends ReComponent<{}, { count: number }, Action> {
54
57
instance . someClassProperty = 1 ;
55
58
// $ExpectError - `instance.someClassProperty` has to be number
56
59
instance . someClassProperty = "1" ;
57
-
58
60
} ) ;
59
61
}
60
62
}
@@ -63,9 +65,9 @@ class UpdateTypes extends ReComponent<{}, { count: number }, Action> {
63
65
class TypedActionTypes extends ReComponent <
64
66
{ } ,
65
67
{ count : number } ,
66
- { | type : ' CLICK' | }
68
+ { | type : " CLICK" | }
67
69
> {
68
- handleClick = ( ) => this . send ( { type : ' CLICK' } ) ;
70
+ handleClick = ( ) => this . send ( { type : " CLICK" } ) ;
69
71
70
72
static reducer ( action , state ) {
71
73
switch ( action . type ) {
@@ -105,7 +107,7 @@ const absurd = <T>(x: empty): T => {
105
107
class ExhaustivelyTypedFailingActionTypes extends ReComponent<
106
108
{ } ,
107
109
{ count : number } ,
108
- { | type : ' CLICK' | } | { | type : ' CLACK' | }
110
+ { | type : " CLICK" | } | { | type : " CLACK" | }
109
111
> {
110
112
static reducer ( action , state ) {
111
113
switch ( action . type ) {
@@ -139,16 +141,17 @@ class ExhaustivelyTypedPassingActionTypes extends ReComponent<
139
141
}
140
142
}
141
143
142
-
143
144
class FailingPayloadType extends ReComponent <
144
145
{ } ,
145
146
{ count : number , awesome : boolean } ,
146
147
{ type : "CLICK" , payload : number } | { type : "CLACK" , payload : boolean }
147
148
> {
148
149
// $ExpectError - `clicks` should be `number`
149
- handleClick = ( clicks : boolean ) => this . send ( { type : 'CLICK' , payload : clicks } ) ;
150
+ handleClick = ( clicks : boolean ) =>
151
+ this . send ( { type : "CLICK" , payload : clicks } ) ;
150
152
// $ExpectError - `awesome` should be `boolean`
151
- handleClack = ( awesome : number ) => this . send ( { type : 'CLACK' , payload : awesome } ) ;
153
+ handleClack = ( awesome : number ) =>
154
+ this . send ( { type : "CLACK" , payload : awesome } ) ;
152
155
153
156
static reducer ( action , state ) {
154
157
switch ( action . type ) {
@@ -170,9 +173,11 @@ class PassingPayloadType extends ReComponent<
170
173
{ } ,
171
174
{ count : number , awesome : boolean } ,
172
175
{ type : "CLICK" , payload : number } | { type : "CLACK" , payload : boolean }
173
- > {
174
- handleClick = ( clicks : number ) => this . send ( { type : 'CLICK' , payload : clicks } ) ;
175
- handleClack = ( awesome : boolean ) => this . send ( { type : 'CLACK' , payload : awesome } ) ;
176
+ > {
177
+ handleClick = ( clicks : number ) =>
178
+ this . send ( { type : "CLICK" , payload : clicks } ) ;
179
+ handleClack = ( awesome : boolean ) =>
180
+ this . send ( { type : "CLACK" , payload : awesome } ) ;
176
181
177
182
static reducer ( action , state ) {
178
183
switch ( action . type ) {
@@ -191,7 +196,7 @@ class PassingPayloadType extends ReComponent<
191
196
class CreateSenderTest extends ReComponent <
192
197
{ } ,
193
198
{ count : number } ,
194
- { | type : ' CLICK ' | } | { | type : ' CLACK ' , payload : number | }
199
+ { | type : " CLICK " | } | { | type : " CLACK " , payload : number | }
195
200
> {
196
201
handleClick = this . createSender ( "CLICK" ) ;
197
202
handleClack = this . createSender ( "CLACK ") ;
0 commit comments