Migrate the client's code to TypeScript
This issue is here to discuss the migration strategy of the client to typescript. With !1333 (merged) and the correction of the error related to the package.json, we could enforce TSC checks for the client as well, to avoid introduction of new typing errors/inconsistancies (this can happen quite easily, if the script is not run).
As the migration will be long, and might not be the most interesting part or the dev, I would like to discuss the approach we should have to migrate step by step to typescript. If possible, big MR should be prevented to ease the review process.
From my tests:
@types/react-redux, and take advantage of the type infering in
connectraises 300/400 compiler errors, which require basically typing the store first (so installing this dep, seems to be the final step, from what I have seen).
- Migrating client/models is easy, I have the code, I will submit it soon (this is the prerequisite to types stores.)
- Migrating the store to TS can be painfull, either because the files themselves are quite big (look at banks.js), or because some typings have impact on all the files and require all store files to be migrated to TSC.
- Just typing the getters (ie without using typescript) will have impact on the full code (I tried it already).
- Typing the reducers (with the store), can be complex without migrating the full file to typescript (there seem to need some type coercion when updeep.update is used (updeep.update is the default export of updeep), which is not possible using JSDoc.
- the generation of fail/success action creators from basic, with the current code, leads to the need to type coercion (and typescript).
With this first analysis, the best approach, seems to me that this would be :
- Migrate client/models to typescript. Migrating the helpers to ts might be interesting, but I don't see a huge impact on the existing code, but there are some works to migrated the helpers.
- In the store, type the substates using JSDoc comments, and type as much as possible the functions / methods / reducers except the action creators. And fix the impacts in the rest of the code.
- Once the store is fully types with JSDoc, without needing to coerce the type (so using typescript), migrate the files to TS (normally, the biggest changes to the code will already we done).
- Evaluate the impact of installing
@types/react-reduxand determine whether type coercion is necessary.
- Migrate the JSX code to TSX
- If needed, install
- Enjoy a fresh beer.
@all what do you think ?