@@ -22,8 +22,8 @@ _Found it useful? Want more updates?_
22
22
23
23
## ** What's new?**
24
24
25
- :tada : _ Now updated to support ** TypeScript v3.7 ** _ :tada :
26
- :rocket : _ Updated to
` [email protected] .x ` :rocket :
25
+ :tada : _ Now updated to support ** TypeScript v4.6 ** _ :tada :
26
+ :rocket : _ Updated to
` [email protected] ` :rocket :
27
27
28
28
<hr /><br />
29
29
@@ -330,12 +330,12 @@ export const FCCounter: React.FC<Props> = props => {
330
330
` ` ` tsx
331
331
import * as React from ' react' ;
332
332
333
- type Props = {
333
+ type Props = React . PropsWithChildren < {
334
334
className? : string ;
335
335
style? : React .CSSProperties ;
336
- };
336
+ }> ;
337
337
338
- export const FCSpreadAttributes : React .FC < Props > = props => {
338
+ export const FCSpreadAttributes : React .FC < Props > = ( props ) => {
339
339
const { children, ... restProps } = props ;
340
340
341
341
return <div { ... restProps } >{ children } </div >;
@@ -722,9 +722,9 @@ export const withState = <BaseProps extends InjectedProps>(
722
722
723
723
return (
724
724
<BaseComponent
725
+ { ... (restProps as BaseProps )}
725
726
count = { count } // injected
726
727
onIncrement = { this .handleIncrement } // injected
727
- { ... (restProps as BaseProps )}
728
728
/>
729
729
);
730
730
}
@@ -761,9 +761,9 @@ const MISSING_ERROR = 'Error was swallowed during propagation.';
761
761
export const withErrorBoundary = <BaseProps extends {}>(
762
762
BaseComponent : React .ComponentType <BaseProps >
763
763
) => {
764
- type HocProps = {
764
+ type HocProps = React . PropsWithChildren < {
765
765
// here you can extend hoc with new props
766
- };
766
+ }> ;
767
767
type HocState = {
768
768
readonly error: Error | null | undefined ;
769
769
};
@@ -892,9 +892,9 @@ export const withConnectedCount = <BaseProps extends InjectedProps>(
892
892
893
893
return (
894
894
<BaseComponent
895
+ { ... (restProps as BaseProps )}
895
896
count = { overrideCount || count } // injected
896
897
onIncrement = { onIncrement } // injected
897
- { ... (restProps as BaseProps )}
898
898
/>
899
899
);
900
900
}
@@ -1218,7 +1218,7 @@ type Props = {};
1218
1218
1219
1219
export class ToggleThemeButtonClass extends React .Component <Props > {
1220
1220
static contextType = ThemeContext ;
1221
- context! : React .ContextType <typeof ThemeContext >;
1221
+ declare context: React .ContextType <typeof ThemeContext >;
1222
1222
1223
1223
render() {
1224
1224
const { theme, toggleTheme } = this .context ;
@@ -1557,8 +1557,8 @@ export default combineReducers({
1557
1557
import {
1558
1558
todosReducer as reducer ,
1559
1559
todosActions as actions ,
1560
- TodosState ,
1561
1560
} from ' ./' ;
1561
+ import { TodosState } from ' ./reducer' ;
1562
1562
1563
1563
/**
1564
1564
* FIXTURES
@@ -1640,7 +1640,7 @@ export const logAddAction: Epic<RootAction, RootAction, RootState, Services> = (
1640
1640
1641
1641
` ` ` tsx
1642
1642
import { StateObservable , ActionsObservable } from ' redux-observable' ;
1643
- import { RootState , Services , RootAction } from ' MyTypes' ;
1643
+ import { RootState , RootAction } from ' MyTypes' ;
1644
1644
import { Subject } from ' rxjs' ;
1645
1645
1646
1646
import { add } from ' ./actions' ;
@@ -1650,11 +1650,11 @@ import { logAddAction } from './epics';
1650
1650
// It is decoupled and reusable for all your tests, just put it in a separate file
1651
1651
const services = {
1652
1652
logger: {
1653
- log: jest .fn < Services [ ' logger ' ][ ' log ' ]> (),
1653
+ log: jest .fn (),
1654
1654
},
1655
1655
localStorage: {
1656
- loadState: jest .fn < Services [ ' localStorage ' ][ ' loadState ' ]> (),
1657
- saveState: jest .fn < Services [ ' localStorage ' ][ ' saveState ' ]> (),
1656
+ loadState: jest .fn (),
1657
+ saveState: jest .fn (),
1658
1658
},
1659
1659
};
1660
1660
@@ -1856,16 +1856,19 @@ We have recommended `tsconfig.json` that you can easily add to your project than
1856
1856
1857
1857
` ` ` tsx
1858
1858
{
1859
+ " extends" : " ./node_modules/react-redux-typescript-scripts/tsconfig.json" ,
1859
1860
" include" : [
1860
1861
" src" ,
1861
1862
" typings"
1862
1863
],
1863
1864
" exclude" : [
1864
- " src/**/*.spec.*"
1865
1865
],
1866
- " extends" : " ./node_modules/react-redux-typescript-scripts/tsconfig.json" ,
1867
1866
" compilerOptions" : {
1868
- " types" : [" jest" ], // which global types to use
1867
+ " module" : " ESNext" ,
1868
+ " target" : " ESNext" ,
1869
+ " moduleResolution" : " Node" ,
1870
+ " jsx" : " preserve" ,
1871
+ " strict" : true
1869
1872
}
1870
1873
}
1871
1874
@@ -1912,16 +1915,9 @@ We have recommended config that will automatically add a parser & plugin for Typ
1912
1915
module .exports = {
1913
1916
root: true ,
1914
1917
parser: ' @typescript-eslint/parser' ,
1915
- plugins: [
1916
- ' @typescript-eslint' ,
1917
- ],
1918
- extends: [
1919
- ' eslint:recommended' ,
1920
- ' plugin:@typescript-eslint/recommended' ,
1921
- " plugin:react/recommended" ,
1922
- " plugin:react-hooks/recommended" ,
1923
- ' prettier'
1924
- ],
1918
+ plugins: [' @typescript-eslint' ],
1919
+ extends: [' react-app' , ' prettier' ],
1920
+ rules: { ' import/no-anonymous-default-export' : 0 },
1925
1921
};
1926
1922
1927
1923
` ` `
@@ -2047,6 +2043,7 @@ if you cannot find types for a third-party module you can provide your own types
2047
2043
// typings/modules.d.ts
2048
2044
declare module ' MyTypes' ;
2049
2045
declare module ' react-test-renderer' ;
2046
+ declare module ' @storybook/addon-storyshots'
2050
2047
2051
2048
` ` `
2052
2049
0 commit comments