@@ -226,12 +226,12 @@ export interface StatefulCounterProps {
226226 label: string ;
227227}
228228
229- type State = {
230- count: number ;
231- };
229+ interface State {
230+ readonly count: number ;
231+ }
232232
233233export class StatefulCounter extends React .Component <StatefulCounterProps , State > {
234- state: State = {
234+ readonly state: State = {
235235 count: 0 ,
236236 };
237237
@@ -272,11 +272,11 @@ export interface StatefulCounterWithDefaultProps {
272272}
273273
274274interface DefaultProps {
275- initialCount: number ;
275+ readonly initialCount: number ;
276276}
277277
278278interface State {
279- count: number ;
279+ readonly count: number ;
280280}
281281
282282export const StatefulCounterWithDefault : React .ComponentClass < StatefulCounterWithDefaultProps > =
@@ -287,7 +287,7 @@ export const StatefulCounterWithDefault: React.ComponentClass<StatefulCounterWit
287287 initialCount: 0 ,
288288 };
289289
290- state: State = {
290+ readonly state: State = {
291291 count: this .props .initialCount ,
292292 };
293293
@@ -373,11 +373,11 @@ interface NameProviderProps {
373373}
374374
375375interface NameProviderState {
376- name: string ;
376+ readonly name: string ;
377377}
378378
379379export class NameProvider extends React .Component <NameProviderProps , NameProviderState > {
380- state = {
380+ readonly state: NameProviderState = {
381381 name: ' Piotr' ,
382382 };
383383
@@ -403,12 +403,12 @@ export interface MouseProviderProps {
403403}
404404
405405interface MouseProviderState {
406- x: number ;
407- y : number ;
406+ readonly x: number ;
407+ readonly y : number ;
408408}
409409
410410export class MouseProvider extends React .Component <MouseProviderProps , MouseProviderState > {
411- state = { x: 0 , y: 0 };
411+ readonly state: MouseProviderState = { x: 0 , y: 0 };
412412
413413 handleMouseMove = (event : React .MouseEvent <HTMLDivElement >) => {
414414 this .setState ({
@@ -463,14 +463,14 @@ export const withState = <P extends WrappedComponentProps>(
463463 initialCount? : number ;
464464 }
465465 interface State {
466- count: number ;
466+ readonly count: number ;
467467 }
468468
469469 return class WithState extends React .Component <Subtract <P , WrappedComponentProps > & Props , State > {
470470 // Enhance component name for debugging and React-Dev-Tools
471471 static displayName = ` withState(${WrappedComponent .name }) ` ;
472472
473- state: State = {
473+ readonly state: State = {
474474 count: Number (this .props .initialCount ) || 0 ,
475475 };
476476
@@ -532,13 +532,13 @@ export const withErrorBoundary = <P extends WrappedComponentProps>(
532532) => {
533533 interface Props { }
534534 interface State {
535- error: Error | null | undefined ;
535+ readonly error: Error | null | undefined ;
536536 }
537537
538538 return class WithErrorBoundary extends React .Component <Subtract <P , WrappedComponentProps > & Props , State > {
539539 static displayName = ` withErrorBoundary(${WrappedComponent .name }) ` ;
540540
541- state: State = {
541+ readonly state: State = {
542542 error: undefined ,
543543 };
544544
@@ -852,7 +852,7 @@ export type TodosState = {
852852};
853853
854854export type RootState = {
855- todos: TodosState ;
855+ readonly todos: TodosState ;
856856};
857857
858858export const todosReducer = combineReducers <TodosState , TodosAction >({
@@ -1345,7 +1345,8 @@ configure({ adapter: new Adapter() });
13451345 // in webpack you need to add -> resolve: { alias: { '@src': PATH_TO_SRC } }
13461346 },
13471347 " outDir" : " dist/" , // target for compiled files
1348- " allowSyntheticDefaultImports" : true , // no errors on commonjs default import
1348+ " allowSyntheticDefaultImports" : true , // no errors with commonjs modules interop
1349+ " esModuleInterop" : true ,
13491350 " allowJs" : true , // include js files
13501351 " checkJs" : true , // typecheck js files
13511352 " declaration" : false , // don't emit declarations
0 commit comments