Vue: Improving Flow types

Created on 8 Dec 2016  路  4Comments  路  Source: vuejs/vue

In files like https://github.com/vuejs/vue/blob/dev/flow/component.js there's a lot of uses of any, Object, and Function.

I'm currently improving the documentation around this in Flow, because we don't do a good enough job of explaining it right now. Sorry about that.

These types aren't actually type-safe. They are there for convenience purposes.

  • Instead of any you should use mixed (or a more specific type).
  • Instead of Function you should use (type, type) => type
  • Instead of Object you should use { prop: type } or { [key: type]: type } (for maps)

This will drastically improve user's experience with Vue using Flow.

contribution welcome improvement

Most helpful comment

Yep, it could definitely use some improvements! The declarations were added mid-way when a pure ES codebase was already in place, so there are quite a few places I was just trying to get by. My Flow knowledge is also limited so I'd appreciate PRs.

All 4 comments

Yep, it could definitely use some improvements! The declarations were added mid-way when a pure ES codebase was already in place, so there are quite a few places I was just trying to get by. My Flow knowledge is also limited so I'd appreciate PRs.

@thejameskyle have you any link about using flow with vuejs?
i was try yesterday, but i was have much problems

@yyx990803 It would be great to have documentation like the one that was made for TS.

Is currently someone working on this? If not I would like to try it.

@MarkusToe Thanks for offering to help! :) Currently we are not actively working on improving the typings - we only add/change stuff we find while working on other parts, fixing bugs etc.

So it would be great if you can improve the situation here!

Was this page helpful?
0 / 5 - 0 ratings