Skip to content

Commit f90c2e1

Browse files
committed
Updated to support TypeScript v4.6 and most recent react/redux/create-react-app
1 parent 1c2e5a6 commit f90c2e1

16 files changed

+146
-163
lines changed

Diff for: README.md

+25-28
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ _Found it useful? Want more updates?_
2222

2323
## **What's new?**
2424

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:
2727

2828
<hr/><br/>
2929

@@ -330,12 +330,12 @@ export const FCCounter: React.FC<Props> = props => {
330330
```tsx
331331
import * as React from 'react';
332332

333-
type Props = {
333+
type Props = React.PropsWithChildren<{
334334
className?: string;
335335
style?: React.CSSProperties;
336-
};
336+
}>;
337337

338-
export const FCSpreadAttributes: React.FC<Props> = props => {
338+
export const FCSpreadAttributes: React.FC<Props> = (props) => {
339339
const { children, ...restProps } = props;
340340

341341
return <div {...restProps}>{children}</div>;
@@ -722,9 +722,9 @@ export const withState = <BaseProps extends InjectedProps>(
722722

723723
return (
724724
<BaseComponent
725+
{...(restProps as BaseProps)}
725726
count={count} // injected
726727
onIncrement={this.handleIncrement} // injected
727-
{...(restProps as BaseProps)}
728728
/>
729729
);
730730
}
@@ -761,9 +761,9 @@ const MISSING_ERROR = 'Error was swallowed during propagation.';
761761
export const withErrorBoundary = <BaseProps extends {}>(
762762
BaseComponent: React.ComponentType<BaseProps>
763763
) => {
764-
type HocProps = {
764+
type HocProps = React.PropsWithChildren<{
765765
// here you can extend hoc with new props
766-
};
766+
}>;
767767
type HocState = {
768768
readonly error: Error | null | undefined;
769769
};
@@ -892,9 +892,9 @@ export const withConnectedCount = <BaseProps extends InjectedProps>(
892892

893893
return (
894894
<BaseComponent
895+
{...(restProps as BaseProps)}
895896
count={overrideCount || count} // injected
896897
onIncrement={onIncrement} // injected
897-
{...(restProps as BaseProps)}
898898
/>
899899
);
900900
}
@@ -1218,7 +1218,7 @@ type Props = {};
12181218

12191219
export class ToggleThemeButtonClass extends React.Component<Props> {
12201220
static contextType = ThemeContext;
1221-
context!: React.ContextType<typeof ThemeContext>;
1221+
declare context: React.ContextType<typeof ThemeContext>;
12221222

12231223
render() {
12241224
const { theme, toggleTheme } = this.context;
@@ -1557,8 +1557,8 @@ export default combineReducers({
15571557
import {
15581558
todosReducer as reducer,
15591559
todosActions as actions,
1560-
TodosState,
15611560
} from './';
1561+
import { TodosState } from './reducer';
15621562

15631563
/**
15641564
* FIXTURES
@@ -1640,7 +1640,7 @@ export const logAddAction: Epic<RootAction, RootAction, RootState, Services> = (
16401640
16411641
```tsx
16421642
import { StateObservable, ActionsObservable } from 'redux-observable';
1643-
import { RootState, Services, RootAction } from 'MyTypes';
1643+
import { RootState, RootAction } from 'MyTypes';
16441644
import { Subject } from 'rxjs';
16451645

16461646
import { add } from './actions';
@@ -1650,11 +1650,11 @@ import { logAddAction } from './epics';
16501650
// It is decoupled and reusable for all your tests, just put it in a separate file
16511651
const services = {
16521652
logger: {
1653-
log: jest.fn<Services['logger']['log']>(),
1653+
log: jest.fn(),
16541654
},
16551655
localStorage: {
1656-
loadState: jest.fn<Services['localStorage']['loadState']>(),
1657-
saveState: jest.fn<Services['localStorage']['saveState']>(),
1656+
loadState: jest.fn(),
1657+
saveState: jest.fn(),
16581658
},
16591659
};
16601660

@@ -1856,16 +1856,19 @@ We have recommended `tsconfig.json` that you can easily add to your project than
18561856
18571857
```tsx
18581858
{
1859+
"extends": "./node_modules/react-redux-typescript-scripts/tsconfig.json",
18591860
"include": [
18601861
"src",
18611862
"typings"
18621863
],
18631864
"exclude": [
1864-
"src/**/*.spec.*"
18651865
],
1866-
"extends": "./node_modules/react-redux-typescript-scripts/tsconfig.json",
18671866
"compilerOptions": {
1868-
"types": ["jest"], // which global types to use
1867+
"module": "ESNext",
1868+
"target": "ESNext",
1869+
"moduleResolution": "Node",
1870+
"jsx": "preserve",
1871+
"strict": true
18691872
}
18701873
}
18711874

@@ -1912,16 +1915,9 @@ We have recommended config that will automatically add a parser & plugin for Typ
19121915
module.exports = {
19131916
root: true,
19141917
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 },
19251921
};
19261922

19271923
```
@@ -2047,6 +2043,7 @@ if you cannot find types for a third-party module you can provide your own types
20472043
// typings/modules.d.ts
20482044
declare module 'MyTypes';
20492045
declare module 'react-test-renderer';
2046+
declare module '@storybook/addon-storyshots'
20502047

20512048
```
20522049

Diff for: README_SOURCE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ _Found it useful? Want more updates?_
2222

2323
## **What's new?**
2424

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:
2727

2828
<hr/><br/>
2929

0 commit comments

Comments
 (0)