Skip to content
New issue

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

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

Already on GitHub? # 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 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 August 15, 2019 12:52
* 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
@netlify
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 August 29, 2019 15:36
* 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 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 September 5, 2019 14:08
* 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
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...

@jednano
Copy link
Contributor

jednano 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
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
@timdorr timdorr deleted the ts-conversion branch September 6, 2019 20:30
@phryneas
Copy link
Member

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

@jednano
Copy link
Contributor

jednano commented Sep 6, 2019

rollup-plugin-dts looks like a great solution!

@jednano jednano mentioned this pull request Sep 7, 2019
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
[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
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
[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
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port to TypeScript
9 participants