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

[Meta PR] Convert to TypeScript #3536

merged 47 commits into from Sep 6, 2019

Conversation

@timdorr
Copy link
Member

timdorr commented Aug 29, 2019

This is just a PR tracking our ts-conversion branch so we can have a quick overview of the status of things, commentable code, and a big green merge button to finish things up.

Closes #3500

cellog and others added 23 commits Aug 15, 2019
* scaffolding for typescript

* add jest types so tests will compile

* remove rollup-plugin-typescript2, probably don't need it

* add missing eslint-import

* fix linting errors
* fix replaceReducer type

* remove extraneous type

* Update the JSDoc so IDEs don't complain.

* new test for replaceReducers


Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com>
* Fix linter configuration for test files

* Add separate ESLint config to test/typescript

* Also lint TypeScript files in examples
* fix typescript config for rollup

* h/t @timdorr remove need for .rpt2_cache ignore
* convert applyMiddleware.js to typescript

* vastly improve the definition of middleware types
@timdorr timdorr added the typescript label Aug 29, 2019
@netlify

This comment has been minimized.

Copy link

netlify bot commented Aug 29, 2019

Deploy preview for redux-docs ready!

Built with commit d8417e8

https://deploy-preview-3536--redux-docs.netlify.com

cellog and others added 5 commits Aug 29, 2019
* convert combineReducers to typescript

* use idiomatic JS
* fix config

* export types

* use export from, reorganize

* fix stupid eslint rule breakage
* extract store types from index.d.ts

* move storeTypes.ts into types/

* Rename storeTypes.ts to store.ts


Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com>
@timdorr

This comment has been minimized.

Copy link
Member Author

timdorr commented Aug 31, 2019

Yes, I'll probably do a rebase and merge specifically, so the commits don't appear as a separate tree in the history.

cellog added 7 commits Sep 2, 2019
…store.ts (#3548)

* use new store types from types/store.ts

* use new reducer types from types/reducers.ts
* add overloads to compose.ts

* add applyMiddleware overload fixes
@timdorr timdorr mentioned this pull request Sep 3, 2019
* fix replaceReducer with a store enhancer

* remove erroneous restriction on StateExt

* remove the other extension - our store enhancer might add array functionality, for instance

* add reasonable defaults for Ext and StateExt

* fix state, add a test for non-object-based state

* add verification that store extension is also passed to replaceReducer

* better fix: set state default based on what base type it is

* fix array test

* fix typing of StateExt

* add mhelmerson example

* fix replaceReducer, so that it infers types, fix example test

* fix the weird type hacks in the test

* add final working example

* update based on PR type changes

* fix type

* update tests to reflect complete examples

* merge the changes from index.d.ts into types/store.ts

* extend store type

* much better approach: only extend the state when we have an extension

* fix typing issues not caught before

* add link to the place I learned about this
src/types/middleware.ts Outdated Show resolved Hide resolved
cellog and others added 2 commits Sep 5, 2019
* fully move away from index.d.ts

* build types into the types/ directory

* remove autogenerated types dir

* ignore auto-generated types

* better type building, also clean old definitions

* use types instead of typings

Co-Authored-By: Jed Mao <jedmao@users.noreply.github.com>

* Don't build declaration maps
@timdorr

This comment has been minimized.

Copy link
Member Author

timdorr commented Sep 5, 2019

I'm going to hold off #3563 until after this, since it's an enhancement to the types. I think we have everything in place now. Let's see what the CI says...

@jedmao

This comment has been minimized.

Copy link
Contributor

jedmao commented Sep 5, 2019

CI is happy, but there's still an issue with type duplication and resolution that I fixed in #3564

* Defer to rollup TS plugin to build types

* index.ts -> redux.js, redux.d.ts

* Only output one copy of the types.

This also puts them back into the types path. However, I don't know how to have them output as a single file bundle to match our other outputs.

* Remove the move


Co-authored-by: Tim Dorr <git@timdorr.com>
@timdorr

This comment has been minimized.

Copy link
Member Author

timdorr commented Sep 6, 2019

OK, one last thing I'd like to do is flatten the types to a single bundle. But I don't think that's critical to move on to the next stage: enhancement!

Thanks to everyone for your help thus far!

@timdorr timdorr merged commit 9d32738 into master Sep 6, 2019
7 checks passed
7 checks passed
Header rules - redux-docs No header rules processed
Details
Pages changed - redux-docs All files already uploaded
Details
Mixed content - redux-docs No mixed content detected
Details
Redirect rules - redux-docs 111 redirect rules processed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
netlify/redux-docs/deploy-preview Deploy preview ready!
Details
@timdorr timdorr deleted the ts-conversion branch Sep 6, 2019
@phryneas

This comment has been minimized.

Copy link

phryneas commented Sep 6, 2019

OK, one last thing I'd like to do is flatten the types to a single bundle. But I don't think that's critical to move on to the next stage: enhancement!

Thanks to everyone for your help thus far!

Very cool. 🎆

One thing though:

While I see you are already aware of the "single bundle", I just wanted to chime in on how important that can be - please don't do a release before having the single type bundle:

@babel/preset-typescript has severe problems with type re-exports ( babel/babel#8361 or babel/babel-loader#603 among dozens of others) that sometimes make libraries with multiple typings files & re-exports almost impossible to use with a webpack+babel-typescript setup.
If you are looking for solutions, there are some mentioned in jaredpalmer/tsdx#80, but I haven't found anything I am happy with yet - if you find something better, please let me know :)

@jedmao

This comment has been minimized.

Copy link
Contributor

jedmao commented Sep 6, 2019

rollup-plugin-dts looks like a great solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
8 participants
You can’t perform that action at this time.