-
Notifications
You must be signed in to change notification settings - Fork 5
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
Stop allowing "unclear types" with Flow #30
Labels
bug
Something isn't working
good first issue
Good for newcomers
help wanted
Extra attention is needed
Milestone
Comments
thibaudcolas
added
bug
Something isn't working
help wanted
Extra attention is needed
good first issue
Good for newcomers
labels
Jan 24, 2019
thibaudcolas
added a commit
that referenced
this issue
Jan 25, 2019
- Replaced Object type annotations with the required shape (not exact, can have extra attributes for convenience). This might raise type issues, but only if there is indeed a problem in the library usage. See [Flow’s `unclear-type`](https://flow.org/en/docs/linting/rule-reference/#toc-unclear-type) rule for further reference. - Use [$ReadOnlyArray<T>](https://flow.org/en/docs/types/arrays/#toc-readonlyarray) in place of Array<T>. This is a supertype of Array (so no change required in implementation), which guarantees draftjs-filters does not mutate arrays.
thibaudcolas
added a commit
that referenced
this issue
Jan 25, 2019
thibaudcolas
added a commit
that referenced
this issue
Jan 25, 2019
- Replaced Object type annotations with the required shape (not exact, can have extra attributes for convenience). This might raise type issues, but only if there is indeed a problem in the library usage. See [Flow’s `unclear-type`](https://flow.org/en/docs/linting/rule-reference/#toc-unclear-type) rule for further reference. - Use [$ReadOnlyArray<T>](https://flow.org/en/docs/types/arrays/#toc-readonlyarray) in place of Array<T>. This is a supertype of Array (so no change required in implementation), which guarantees draftjs-filters does not mutate arrays.
thibaudcolas
added a commit
that referenced
this issue
Jan 25, 2019
thibaudcolas
added a commit
that referenced
this issue
Jan 25, 2019
## [2.2.2](v2.2.1...v2.2.2) (2019-01-25) ### Bug Fixes * **api:** use more precise Flow types for public APIs. Fix [#30](#30) ([f274aaa](f274aaa))
🎉 This issue is fixed in v2.2.2, available on npm: draftjs-filters@2.2.2. Generated by 📦🚀 semantic-release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
good first issue
Good for newcomers
help wanted
Extra attention is needed
Bug/documentation issue. Unclear types (
Array
,Object
,Function
) shouldn't be allowed in the code.What is the current behavior?
At the moment,
.flowconfig
turns off theunclear-type
linting rule, which allows code to be written with types likeArray<Object>
. This is problematic because those types end up in the documentation, and aren't really helpful when the API signature of functions actually expects specific shapes for those objects.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. GIFs and screenshots are very helpful too.
For example –
shouldKeepEntityByAttribute
declares it expects an Array of Objects:draftjs-filters/src/lib/filters/entities.js
Lines 145 to 149 in 428f7f7
the
whitelist
attribute’s values are actuallystring | boolean
. This is not clear in the type definition ofshouldKeepEntityByAttribute
, and as a result the type definition offilterEditorState
is out of date:draftjs-filters/src/lib/filters/editor.js
Lines 39 to 41 in 428f7f7
What is the expected behavior?
All functions should be typed with exact types.
Which versions of the filters or of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of the filters / Draft.js?
This has always been the case. It’s more problematic now because the types are used to generate documentation (#26), which is not as useful as it could be / wrong / imprecise.
The text was updated successfully, but these errors were encountered: