Skip to content

Commit ba6e67c

Browse files
committed
Updated deps and refactored code to fix breaking changes
1 parent ddca307 commit ba6e67c

File tree

7 files changed

+5960
-2597
lines changed

7 files changed

+5960
-2597
lines changed

playground/package-lock.json

+5,914-2,538
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/package.json

+31-31
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,34 @@
2121
"build-storybook": "build-storybook -s public"
2222
},
2323
"dependencies": {
24-
"@types/jest": "24.0.11",
25-
"@types/node": "11.13.8",
26-
"@types/prop-types": "15.7.1",
27-
"@types/react": "16.8.14",
28-
"@types/react-dom": "16.8.4",
29-
"@types/react-redux": "7.0.8",
30-
"@types/react-router-dom": "4.3.2",
24+
"@testing-library/react": "9.3.1",
25+
"@types/jest": "24.0.21",
26+
"@types/node": "12.12.5",
27+
"@types/prop-types": "15.7.3",
28+
"@types/react": "16.9.11",
29+
"@types/react-dom": "16.9.3",
30+
"@types/react-redux": "7.1.5",
31+
"@types/react-router-dom": "5.1.2",
3132
"axios": "^0.19.0",
32-
"connected-react-router": "6.5.0",
33+
"connected-react-router": "6.5.2",
3334
"cuid": "2.1.6",
3435
"prop-types": "15.7.2",
35-
"react": "16.8.6",
36-
"react-dom": "16.8.6",
37-
"react-redux": "7.1.0",
38-
"react-redux-typescript-scripts": "1.5.0",
39-
"react-router-dom": "4.3.1",
40-
"react-scripts": "3.0.1",
41-
"react-testing-library": "7.0.0",
42-
"redux": "4.0.1",
43-
"redux-observable": "1.1.0",
36+
"react": "16.11.0",
37+
"react-dom": "16.11.0",
38+
"react-redux": "7.1.1",
39+
"react-redux-typescript-scripts": "1.6.2",
40+
"react-router-dom": "5.1.2",
41+
"react-scripts": "3.2.0",
42+
"redux": "4.0.4",
43+
"redux-observable": "1.2.0",
4444
"redux-thunk": "2.3.0",
4545
"reselect": "4.0.0",
46-
"rxjs": "6.5.1",
47-
"tslib": "1.9.3",
48-
"tslint": "5.16.0",
49-
"typesafe-actions": "4.2.0",
50-
"typescript": "3.4.5",
51-
"utility-types": "3.5.0"
46+
"rxjs": "6.5.3",
47+
"tslib": "1.10.0",
48+
"tslint": "5.20.0",
49+
"typesafe-actions": "5.1.0",
50+
"typescript": "3.7.1-rc",
51+
"utility-types": "3.9.0"
5252
},
5353
"browserslist": [
5454
">0.2%",
@@ -57,14 +57,14 @@
5757
"not op_mini all"
5858
],
5959
"devDependencies": {
60-
"@storybook/addon-actions": "5.1.9",
61-
"@storybook/addon-links": "5.1.9",
62-
"@storybook/addon-storyshots": "5.1.9",
63-
"@storybook/addons": "5.1.9",
64-
"@storybook/react": "5.1.9",
65-
"@types/storybook__addon-storyshots": "4.0.1",
60+
"@storybook/addon-actions": "5.2.5",
61+
"@storybook/addon-links": "5.2.5",
62+
"@storybook/addon-storyshots": "5.2.5",
63+
"@storybook/addons": "5.2.5",
64+
"@storybook/react": "5.2.5",
65+
"@types/storybook__addon-storyshots": "5.1.1",
6666
"@types/storybook__react": "4.0.2",
67-
"react-test-renderer": "16.8.6",
68-
"require-context.macro": "1.0.4"
67+
"react-test-renderer": "16.11.0",
68+
"require-context.macro": "1.2.2"
6969
}
7070
}

playground/src/components/class-counter-with-default-props.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ export class ClassCounterWithDefaultProps extends React.Component<
2121
count: this.props.initialCount,
2222
};
2323

24-
componentWillReceiveProps({ initialCount }: Props) {
25-
if (initialCount != null && initialCount !== this.props.initialCount) {
26-
this.setState({ count: initialCount });
27-
}
28-
}
29-
3024
handleIncrement = () => {
3125
this.setState({ count: this.state.count + 1 });
3226
};

playground/src/connected/fc-counter-connected-own-props.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { createStore, combineReducers } from 'redux';
33
import { Provider } from 'react-redux';
4-
import { render, fireEvent, cleanup } from 'react-testing-library';
4+
import { render, fireEvent, cleanup } from '@testing-library/react';
55

66
import { FCCounterConnectedOwnProps as ConnectedCounter } from './fc-counter-connected-own-props';
77

Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import cuid from 'cuid';
2-
import { createStandardAction } from 'typesafe-actions';
2+
import { createAction } from 'typesafe-actions';
33

44
import { TodosFilter, Todo } from './models';
55

66
const ADD = 'todos/ADD';
77
const TOGGLE = 'todos/TOGGLE';
88
const CHANGE_FILTER = 'todos/CHANGE_FILTER';
99

10-
export const add = createStandardAction(ADD).map(
11-
(payload: { title: string }) => ({
12-
payload: {
13-
...payload,
14-
id: cuid(),
15-
completed: false,
16-
} as Todo,
17-
})
18-
);
10+
export const add = createAction(ADD, (title: string) => ({
11+
id: cuid(),
12+
title,
13+
}))<Todo>();
1914

20-
export const toggle = createStandardAction(TOGGLE)<{ id: string }>();
15+
export const toggle = createAction(TOGGLE)<{ id: string }>();
2116

22-
export const changeFilter = createStandardAction(CHANGE_FILTER)<TodosFilter>();
17+
export const changeFilter = createAction(CHANGE_FILTER)<TodosFilter>();

playground/src/features/todos/reducer-ta.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ const initialState: TodosState = {
1414
};
1515

1616
const todos = createReducer(initialState.todos)
17-
.handleAction(ADD, (state, action) => [...state, action.payload])
18-
.handleAction(TOGGLE, (state, action) =>
17+
.handleType(ADD, (state, action) => [...state, action.payload])
18+
.handleType(TOGGLE, (state, action) =>
1919
state.map(item =>
2020
item.id === action.payload
2121
? { ...item, completed: !item.completed }
2222
: item
2323
)
2424
);
2525

26-
const todosFilter = createReducer(initialState.todosFilter).handleAction(
26+
const todosFilter = createReducer(initialState.todosFilter).handleType(
2727
CHANGE_FILTER,
2828
(state, action) => action.payload
2929
);

playground/src/models/nominal-types.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ const createName = (name: string): Name => {
1010
return name as any;
1111
};
1212

13-
// Method 2: using "enum"
14-
export enum SurnameBrand {}
15-
type Surname = SurnameBrand & string;
16-
// interface Surname extends String { _brand: 'Surname'; }
13+
// Method 2: using "type"
14+
type Surname = string & { _brand: 'Surname' };
1715
const createSurname = (surname: string): Surname => {
1816
// validation of business rules
1917
return surname as any;
@@ -39,5 +37,5 @@ person.surname = createSurname('Mate'); // OK!
3937

4038
// easy casting to supertype
4139
export let str: string;
42-
str = person.name.toString();
43-
str = person.surname;
40+
str = person.name.toString(); // Method 1 & Method 2
41+
str = person.surname; // Method 2 only

0 commit comments

Comments
 (0)