Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Meta PR] Convert to TypeScript #3536

Merged
merged 47 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
76d1f98
scaffolding for typescript (#3504)
cellog Aug 15, 2019
9ab13e1
migrate applyMiddleware test to typescript (#3505)
cellog Aug 16, 2019
b67654c
migrate bindActionCreators test to typescript (#3506)
cellog Aug 16, 2019
577dd90
convert the compose test to typescript (#3509)
cellog Aug 16, 2019
2c1af36
fix replaceReducer type (#3507)
cellog Aug 16, 2019
9a62a31
convert combineReducers test to typescript (#3508)
cellog Aug 16, 2019
f6a2122
migrate index.js to typescript (#3513)
cellog Aug 16, 2019
e48c389
convert the createStore test to typescript - and run the tests (#3510)
cellog Aug 16, 2019
601d54d
convert utils/isPlainObject test to typescript (#3511)
cellog Aug 16, 2019
2f2cd31
migrate warning.spec.ts to typescript (#3512)
cellog Aug 16, 2019
a8b133c
migrate typescript.spec.ts to typescript (#3516)
cellog Aug 18, 2019
20f604d
migrate test helpers to typescript (#3515)
cellog Aug 18, 2019
2e15b68
Resolve TS extensions with node-resolve plugin (#3517)
nickserv Aug 19, 2019
aa8b325
TypeScript: Fix linter configuration for test files (#3518)
nickserv Aug 19, 2019
e5fba83
add a new test to verify replaceReducer typings work (#3521)
cellog Aug 20, 2019
a68f48e
fix typescript config for rollup (#3519)
cellog Aug 22, 2019
4f7ff64
fix warning in test (#3527)
cellog Aug 29, 2019
9c8e440
Use new default cache root (#3528)
nickserv Aug 29, 2019
e638c96
convert bindActionCreators to typescript (#3530)
cellog Aug 29, 2019
aa6d410
Convert applyMiddleware.js to typescript (#3529)
cellog Aug 29, 2019
7a669b9
convert compose to typescript (#3532)
cellog Aug 29, 2019
b0e8219
convert utils/ to typescript (#3534)
cellog Aug 29, 2019
9b70f1c
convert createStore to typescript (#3533)
cellog Aug 29, 2019
ff8af9f
convert combineReducers to typescript (#3531)
cellog Aug 29, 2019
4132d41
remove unused type (#3538)
cellog Aug 30, 2019
c43fc3a
merge type definitions from index.d.ts into combineReducers (#3539)
cellog Aug 30, 2019
7b0c760
export types, prepare TS config for migrating files (#3537)
cellog Aug 30, 2019
146791c
extract store types from index.d.ts (#3540)
cellog Aug 30, 2019
7bd5846
extract action types from index.d.ts (#3541)
cellog Aug 30, 2019
8735e56
Extract reducer types from index.d.ts (#3542)
cellog Aug 30, 2019
0c70abc
remove duplicate types (they live in types/reducers.ts) (#3544)
cellog Aug 30, 2019
956b0e9
extract middleware types from index.d.ts (#3543)
cellog Aug 30, 2019
addcacb
use the new action types (#3545)
cellog Aug 30, 2019
ed4f090
fix type import of CombinedState (#3546)
cellog Aug 30, 2019
35f2e1a
import types from src/types (#3549)
cellog Aug 31, 2019
81329e5
use new middleware types from types/middleware.ts (#3547)
cellog Aug 31, 2019
40d9e1e
add missing type exports (#3556)
cellog Sep 2, 2019
65afa45
use new reducer types from types/reducers.ts, store types from types/…
cellog Sep 2, 2019
6d96545
fix typings of createStore and import of Reducer type (#3555)
cellog Sep 2, 2019
a450fbd
fix combineReducers overload exports, and import of Reducer type (#3554)
cellog Sep 2, 2019
dd6639a
fix import inside enhancers typescript test (#3559)
cellog Sep 2, 2019
8112c95
add overloads to compose.ts and applyMiddleware.ts (#3558)
cellog Sep 2, 2019
dbc95c8
fixes to bindActionCreators overloads (#3552)
cellog Sep 2, 2019
066fa81
fix replaceReducer with a store enhancer (#3524)
cellog Sep 3, 2019
766f934
fully move away from index.d.ts (#3561)
cellog Sep 5, 2019
9e71b4c
fix TSDoc comments (#3560)
jedmao Sep 5, 2019
d8417e8
Defer to rollup TS plugin to build types (#3564)
jedmao Sep 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { NODE_ENV } = process.env

module.exports = {
presets: [
'@babel/typescript',
[
'@babel/env',
{
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
**/server.js
**/webpack.config*.js
**/flow-typed/**
# TODO: figure out a way to lint this using flow instead of typescript
examples/todos-flow
34 changes: 23 additions & 11 deletions .eslintrc.js
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 '_'
}
]
}
}
11 changes: 5 additions & 6 deletions examples/todomvc/src/components/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import App from './App'
import Header from '../containers/Header'
import MainSection from '../containers/MainSection'


const setup = propOverrides => {
const setup = _propOverrides => {
const renderer = createRenderer()
renderer.render(<App />)
const output = renderer.getRenderOutput()
Expand All @@ -16,16 +15,16 @@ describe('components', () => {
describe('Header', () => {
it('should render', () => {
const output = setup()
const [ header ] = output.props.children
const [header] = output.props.children
expect(header.type).toBe(Header)
})
})

describe('Mainsection', () => {
it('should render', () => {
const output = setup()
const [ , mainSection ] = output.props.children
const [, mainSection] = output.props.children
expect(mainSection.type).toBe(MainSection)
})
})
})
})
12 changes: 10 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export function combineReducers<M extends ReducersMapObject<any, any>>(
* dispatched.
*/
export interface Dispatch<A extends Action = AnyAction> {
<T extends A>(action: T): T
<T extends A>(action: T, ...extraArgs: any[]): T
}

/**
Expand Down Expand Up @@ -326,7 +326,9 @@ export interface Store<S = any, A extends Action = AnyAction> {
*
* @param nextReducer The reducer for the store to use instead.
*/
replaceReducer(nextReducer: Reducer<S, A>): void
replaceReducer<NewState = S, NewActions extends A = A>(
nextReducer: Reducer<NewState, NewActions>
): Store<NewState, NewActions>

/**
* Interoperability point for observable/reactive libraries.
Expand Down Expand Up @@ -667,3 +669,9 @@ export function compose<R>(
): (...args: any[]) => R

export function compose<R>(...funcs: Function[]): (...args: any[]) => R

export const __DO_NOT_USE__ActionTypes: {
INIT: string
REPLACE: string
PROBE_UNKNOWN_ACTION: () => string
}
Loading