-
Notifications
You must be signed in to change notification settings - Fork 13
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
Typescript declarations #878
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BREAKING CHANGE: cozy-client now depends on redux 4 > https://github.com/reduxjs/redux/releases > If you're a React user, this is going to be a lot like going from 15 to 16. Not a lot of user-facing changes, but some interesting improvements under the hood. > The major changes (#1342) are around our TypeScript definitions, bundled CommonJS and ES builds, throwing if you subscribe or getState from a reducer, and a bunch of other smaller things. The full changes are listed below.
These are autogenerated from the JSDoc
ptbrowne
force-pushed
the
typescript
branch
3 times, most recently
from
February 25, 2021 16:53
deba998
to
05d8672
Compare
Removed the jsdoc/check-types eslint rule because it was changing Object.<String,String> into object.<String,String> and this did not play well with typescript
For the redux 3 to 4, since the breaking changes are mostly cosmetic and should not impact us (I haven't seen any error), I believe we could have redux@4 as dev dependency and support redux@3 and 4 in peer deps. |
Importing recursively leads to tsc errors > Cannot write file 'client/packages/cozy-client/types/models/note.d.ts' because it would overwrite input file. microsoft/TypeScript#14538 (comment)
Crash--
approved these changes
Mar 1, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incredible work! Once green 👍 ;)
Since the false command was not the last command, its exit status was not "returned" as the exit status of the whole process
jsdoc does not support & for intersection types and will never support it so we need a plugin to convert & to |. More information at https://github.com/chriseaton/jsdoc-plugin-intersection Or we could completely forgo jsdoc and use typescript tooling to generate our doc (this way, no incompatibility between jsdoc and typescript)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The idea here is to use the JSDoc comments that we already have in a lot of files of cozy-client (JSDoc is used to generate API docs automatically) to generate typescript declarations and to typecheck cozy-client at transpile time.
Gains:
Example
In:
Out:
It means that before publishing cozy-client, a typecheck pass will be done.
We continue to use our existing babel transpiler
Typescript only emits declarations (those declarations are then picked up by IDEs to show contextual helps, see screenshots below)
install the Typescript plugin, see screenshots below
Checks that intra cozy-client, methods are called with the right parameters etc...
an error, I think we should have the redux update as part of another
PR. See for the problem TS2315: Type 'Middleware' is not generic reduxjs/redux-thunk#205
@ts-ignore
. I do not think it's problematic.IDE screenshots
Documentation
These two can be useful before reading the PR:
https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html
https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#param-and-returns