@@ -287,56 +287,51 @@ export class StatefulCounter extends React.Component<StatefulCounterProps, State
287
287
` ` ` tsx
288
288
import * as React from ' react' ;
289
289
290
- export interface StatefulCounterWithDefaultProps {
290
+ type Props = Readonly < {
291
291
label: string ;
292
- initialCount ?: number ;
293
- }
294
-
295
- interface DefaultProps {
296
- readonly initialCount: number ;
297
- }
292
+ initialCount: number ;
293
+ }>;
298
294
299
- interface State {
300
- readonly count: number ;
301
- }
295
+ type State = Readonly < {
296
+ count: number ;
297
+ }>;
302
298
303
- export const StatefulCounterWithDefault : React .ComponentClass < StatefulCounterWithDefaultProps > =
304
- class extends React .Component <StatefulCounterWithDefaultProps & DefaultProps > {
305
- // to make defaultProps strictly typed we need to explicitly declare their type
306
- // @see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11640
307
- static defaultProps: DefaultProps = {
308
- initialCount: 0 ,
309
- };
299
+ export class StatefulCounterWithDefault extends React .Component <Props , State > {
300
+ static defaultProps = {
301
+ initialCount: 0 ,
302
+ };
310
303
311
- readonly state: State = {
312
- count: this .props .initialCount ,
313
- };
304
+ readonly state: State = {
305
+ count: this .props .initialCount ,
306
+ };
314
307
315
- componentWillReceiveProps({ initialCount }: StatefulCounterWithDefaultProps ) {
316
- if (initialCount != null && initialCount !== this .props .initialCount ) {
317
- this .setState ({ count: initialCount });
318
- }
308
+ componentWillReceiveProps({ initialCount }: Props ) {
309
+ if (initialCount != null && initialCount !== this .props .initialCount ) {
310
+ this .setState ({ count: initialCount });
319
311
}
312
+ }
320
313
321
- handleIncrement = () => {
322
- this .setState ({ count: this .state .count + 1 });
323
- }
314
+ handleIncrement = () => {
315
+ this .setState ({ count: this .state .count + 1 });
316
+ };
324
317
325
- render() {
326
- const { handleIncrement } = this ;
327
- const { label } = this .props ;
328
- const { count } = this .state ;
318
+ render() {
319
+ const { handleIncrement } = this ;
320
+ const { label } = this .props ;
321
+ const { count } = this .state ;
329
322
330
- return (
331
- <div >
332
- <span >{ label } : { count } </span >
333
- <button type = " button" onClick = { handleIncrement } >
334
- { ` Increment ` }
335
- </button >
336
- </div >
337
- );
338
- }
339
- };
323
+ return (
324
+ <div >
325
+ <span >
326
+ { label } : { count } { ' ' }
327
+ </span >
328
+ <button type = " button" onClick = { handleIncrement } >
329
+ { ` Increment ` }
330
+ </button >
331
+ </div >
332
+ );
333
+ }
334
+ }
340
335
341
336
` ` `
342
337
@@ -1244,7 +1239,6 @@ export const SFCCounterConnectedVerbose =
1244
1239
" no-submodule-imports" : [true , " @src" , " rxjs" ],
1245
1240
" no-this-assignment" : [true , { " allow-destructuring" : true }],
1246
1241
" no-trailing-whitespace" : true ,
1247
- " no-unused-variable" : [true , " react" ],
1248
1242
" object-literal-sort-keys" : false ,
1249
1243
" object-literal-shorthand" : false ,
1250
1244
" one-variable-per-declaration" : [false ],
@@ -1479,7 +1473,6 @@ declare module 'rxjs/Subject' {
1479
1473
// typings/modules.d.ts
1480
1474
declare module ' Types' ;
1481
1475
declare module ' react-test-renderer' ;
1482
- declare module ' enzyme' ;
1483
1476
1484
1477
` ` `
1485
1478
0 commit comments