@@ -287,56 +287,51 @@ export class StatefulCounter extends React.Component<StatefulCounterProps, State
287287` ` ` tsx
288288import * as React from ' react' ;
289289
290- export interface StatefulCounterWithDefaultProps {
290+ type Props = Readonly < {
291291 label: string ;
292- initialCount ?: number ;
293- }
294-
295- interface DefaultProps {
296- readonly initialCount: number ;
297- }
292+ initialCount: number ;
293+ }>;
298294
299- interface State {
300- readonly count: number ;
301- }
295+ type State = Readonly < {
296+ count: number ;
297+ }>;
302298
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+ };
310303
311- readonly state: State = {
312- count: this .props .initialCount ,
313- };
304+ readonly state: State = {
305+ count: this .props .initialCount ,
306+ };
314307
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 });
319311 }
312+ }
320313
321- handleIncrement = () => {
322- this .setState ({ count: this .state .count + 1 });
323- }
314+ handleIncrement = () => {
315+ this .setState ({ count: this .state .count + 1 });
316+ };
324317
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 ;
329322
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+ }
340335
341336` ` `
342337
@@ -1244,7 +1239,6 @@ export const SFCCounterConnectedVerbose =
12441239 " no-submodule-imports" : [true , " @src" , " rxjs" ],
12451240 " no-this-assignment" : [true , { " allow-destructuring" : true }],
12461241 " no-trailing-whitespace" : true ,
1247- " no-unused-variable" : [true , " react" ],
12481242 " object-literal-sort-keys" : false ,
12491243 " object-literal-shorthand" : false ,
12501244 " one-variable-per-declaration" : [false ],
@@ -1479,7 +1473,6 @@ declare module 'rxjs/Subject' {
14791473// typings/modules.d.ts
14801474declare module ' Types' ;
14811475declare module ' react-test-renderer' ;
1482- declare module ' enzyme' ;
14831476
14841477` ` `
14851478
0 commit comments