-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
[Meta PR] Convert to TypeScript Co-authored-by: Gregory Beaver <greg.beaver.cello@gmail.com> Co-authored-by: Nick McCurdy <nick@nickmccurdy.com> Co-authored-by: Jed Mao <jedmao@users.noreply.github.com> Former-commit-id: 3b4f495 Former-commit-id: d429872
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ const { NODE_ENV } = process.env | |
|
||
module.exports = { | ||
presets: [ | ||
'@babel/typescript', | ||
[ | ||
'@babel/env', | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
module.exports = { | ||
extends: 'react-app', | ||
|
||
parser: '@typescript-eslint/parser', | ||
|
||
plugins: ['@typescript-eslint'], | ||
|
||
settings: { | ||
react: { | ||
version: '16.8' | ||
}, | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts', '.tsx'] | ||
}, | ||
'import/resolver': { | ||
// use <root>/tsconfig.json | ||
typescript: {} | ||
} | ||
}, | ||
|
||
rules: { | ||
'jsx-a11y/href-no-hash': 'off' | ||
}, | ||
|
||
overrides: [ | ||
{ | ||
files: 'test/**/*.js', | ||
env: { | ||
jest: true, | ||
}, | ||
}, | ||
], | ||
'jsx-a11y/href-no-hash': 'off', | ||
'no-unused-vars': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ | ||
vars: 'all', | ||
args: 'after-used', | ||
ignoreRestSiblings: true, | ||
argsIgnorePattern: '^_' // ignore unused variables whose name is '_' | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
.DS_Store | ||
*.log | ||
node_modules | ||
|
||
coverage | ||
|
||
dist | ||
lib | ||
es | ||
coverage | ||
types | ||
|
||
website/translated_docs | ||
website/build/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
50e8d018faee8887ed82337fcd1993ad07df0968 | ||
aa8ec2ad318f2542aaf407c9112143f8669dba4e |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6dc69e8d7768ccf0b08dd7b6ed73f57ce5ba7510 | ||
772f99d6b51677bd2cd88345904b9e29c40eb9bd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
07297f2bc2205b6f21539ca6f1c50d96d4cb9096 | ||
27ce0b7bc959177b6a0d4a3dd4ae43fe27f476d3 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f73584325282b69e12dd6caa61ae5bf23c32e64f |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
073a3b58df26f159289b9e854cfd615af6ed9bc9 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
07f9f7bd22ae1cc4dd9a295731960e1e90aac88e |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fcbfd70d7bf2aa262de58be558c4a6008957e7f0 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a75fc2a304526089ddb4af859689430dc4e4b3c6 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
40df5f346de6cd075ce8946e0fa1aa778e9cbc09 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
75215ed7afdeaf3f2e973109805cc779557c8bfb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
d631d988daabb5d9d72c5821122fede3a8e705b2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
d0c41a9d33ce27ca26c1a283564be5b04a6d55e3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aaebb0ad21e3f200568600eb568abbec514e7111 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fefd849b15428a4a294651edc81a3cb7fc373893 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5efecb6902f7abeab5af8892f778346c4bcaeaf7 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
161e00658b64c2fa549317d5b6f68bc83f8646fe |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
d25131cdebad8959ef7eba061752516823b623a8 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5e8ef1db50fc59beceb2aee464b31644368a3669 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
46964ea9cef1aec64487cde982fc7450877410d7 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MiddlewareAPI, Dispatch, AnyAction } from '../..' | ||
|
||
type ThunkAction<T extends any = any> = T extends AnyAction | ||
? AnyAction | ||
: T extends Function | ||
? T | ||
: never | ||
|
||
export function thunk({ dispatch, getState }: MiddlewareAPI) { | ||
return (next: Dispatch) => <T>(action: ThunkAction) => | ||
typeof action === 'function' ? action(dispatch, getState) : next(action) | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c10d3d017ed4b5122d25d5ed2b80309ccadf7cf9 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createStore, combineReducers } from '..' | ||
|
||
describe('replaceReducers test', () => { | ||
it('returns the original store', () => { | ||
const nextReducer = combineReducers({ | ||
foo: (state = 1, _action) => state, | ||
bar: (state = 2, _action) => state | ||
}) | ||
const store = createStore((state, action) => { | ||
if (state === undefined) return { type: 5 } | ||
return action | ||
}) | ||
|
||
const nextStore = store.replaceReducer(nextReducer) | ||
|
||
expect(nextStore).toBe(store) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
rules: { | ||
'no-unused-expressions': 'off', | ||
'@typescript-eslint/no-namespace': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off' | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
e3594a0712d844fe26a2d8836137624dd9e1e73c | ||
f7a15bcd754e609d63e23bddd636288c72d72c1b |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ae2fc5b32dba9f6959659bfcfc901d366ce0217a | ||
cfc608bad3e6370697f8f4ae049df1efc823cd8f |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
72f89988562262cb211a90298d9ca75c3b37bfa4 | ||
9cb125e37a001777f5a3a86146a6b06a746cbbf9 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7259b4884bf70423a7abbd95ced2ef45a9a760c1 | ||
c6d29af6a08539a343f95fedf50be0f8a2927bfa |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
f115b699fe3596e938591ff39767c65032362da0 | ||
46dc9a70160a8144aae157d53f4180200b6e4f13 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7b1c48443c1f0e03751a219d2a4f97258efabfd5 | ||
a0f9afa7f68a7af687107984478c7c4b74367dbd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5a109eeecee5610220b77259d3b0ee175d8dbd74 | ||
f013f83b37aaf1bf8d8183e2bc433a454fa56e9b |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { combineReducers, createStore } from '../..' | ||
|
||
/** | ||
* verify that replaceReducer maintains strict typing if the new types change | ||
*/ | ||
const bar = (state = { value: 'bar' }) => state | ||
const baz = (state = { value: 'baz' }) => state | ||
const ACTION = { | ||
type: 'action' | ||
} | ||
|
||
const originalCompositeReducer = combineReducers({ bar }) | ||
const store = createStore(originalCompositeReducer) | ||
store.dispatch(ACTION) | ||
|
||
const firstState = store.getState() | ||
firstState.bar.value | ||
// typings:expect-error | ||
firstState.baz.value | ||
|
||
const nextStore = store.replaceReducer(combineReducers({ baz })) // returns -> { baz: { value: 'baz' }} | ||
|
||
const nextState = nextStore.getState() | ||
// typings:expect-error | ||
nextState.bar.value | ||
nextState.baz.value |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
123464ce556358be71cad6cb468910c36c2f9a39 | ||
dd7d76296eeac8dd7d6abc7d65a98e7f24bb5bba |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1ef2e9f083e0338a4cf39a2cd6a11df70b0c3abc |