Skip to content

No longer rely on JSDoc types alone #725

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

Closed
tmcw opened this issue Apr 13, 2017 · 3 comments
Closed

No longer rely on JSDoc types alone #725

tmcw opened this issue Apr 13, 2017 · 3 comments
Labels

Comments

@tmcw
Copy link
Member

tmcw commented Apr 13, 2017

Right now documentation.js transforms Flow types to JSDoc types, so that it can run them both through format_type, which is derived from doctrine's formatter. We shouldn't do this anymore: JSDoc types can't cover everything that Flow can.

Possibly we should reverse this process and instead convert JSDoc types to Flow types. We will need to survey what the overlap and intersection of the two are in order to make an informed decision.

JSDoc Flow notes
union yes, string|number yes, string|number https://flow.org/en/docs/types/unions/
intersection no yes https://flow.org/en/docs/types/intersections/ eslint/doctrine#183
nullable yes, ?string yes, ?string https://flow.org/en/docs/types/maybe/
arrays of types yes, Array<string> or string[] or Array.<string> yes, Array<string> or string[] https://flow.org/en/docs/types/arrays/
non-nullable yes, !string no?
intersection no yes, type & type https://flow.org/en/docs/types/intersections/
tuple no yes, [string, number] https://flow.org/en/docs/types/tuples/ google/closure-compiler#379
literal types no yes, 2 https://flow.org/en/docs/types/literals/
@tmcw tmcw added the refactor label Apr 13, 2017
@tmcw
Copy link
Member Author

tmcw commented Apr 24, 2017

Another JSDoc lacking: indexers.

http://usejsdoc.org/tags-type.html

versus

https://flow.org/en/docs/types/objects/#object-type-syntax-a-classtoc-idtoc-object-type-syntax-hreftoc-object-type-syntaxa

There is no way to express

{
  size: number,
  [id: number]: string
}

In JSDoc - you can have a type application or a record type, but not both.

@faassen
Copy link

faassen commented Jun 8, 2017

non-nullable in flow seems to be simply the variable without ? in front of it. So with flow you mark nullability: ?string

@tmcw
Copy link
Member Author

tmcw commented Oct 13, 2017

Punting, moving conversation to dx-spec tmcw/dx-spec#2

@tmcw tmcw closed this as completed Oct 13, 2017
mollymerp pushed a commit to mapbox/mapbox-gl-js that referenced this issue Aug 20, 2018
mollymerp pushed a commit to mapbox/mapbox-gl-js that referenced this issue Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants