Flow: Feature request: flow explain -command to explain the type

Created on 4 Jan 2018  路  4Comments  路  Source: facebook/flow

Some times would be nice to see what flow knows about certain types. Let's take this as an example

I'd like to be able to know what exactly flow thinks type C and type D are. How they are different? Now Flow is more like a black box what comest to resulting types. I can only try out with different ways to see if there are any differences. More practical would be if I could just hover over the type and flow would print the exact type for me as it would be defined. That could be achieved with command like flow explain /path/to/file.js 6 6 this would then print the shape which satisfies type C, something like: {|A: number, B: number|}. This would help a lot to figure out some of the type errors flow gives.

Would that make sense or is it already somehow possible?

E: A tool like try flow to show resulting types would also be really nice btw!

feature request

Most helpful comment

What you're asking for already exists.

flow type-at-pos /path/to/file.js 6 6

All 4 comments

What you're asking for already exists.

flow type-at-pos /path/to/file.js 6 6

@jcready that is not the same. For that piece of code in the link the command returns (unknown) for the position. Also, for other parts it returns very vague types, like object literal or the name of the type. That does not help debugging the type definition at all.

screen shot 2018-07-23 at 18 25 13
screen shot 2018-07-23 at 18 25 30

this is what I see now in try

@stereobooster I believe @villesau wants type C to be displayed as:

type C = {|A: number|} & {|B: number|}
Was this page helpful?
0 / 5 - 0 ratings