Flow: Comment type syntax: There is no comment-based way to deal with imports of types

Created on 18 Jul 2017  路  2Comments  路  Source: facebook/flow

Regarding comment-based type syntax described in https://flow.org/en/docs/types/comments/#comment-types-syntax-a-classtoc-idtoc-comment-types-syntax-hreftoc-comment-types-syntaxa

There does not seem to be a way to import type using comment syntax. That means when I use comment type syntax to annotate a type defined in another file I either have to use Flow import type syntax - negating the whole purpose of comment types - or.. well, there does not seem to be an "or".

Most helpful comment

You can definitely import types using the comment syntax:

// @flow
/*::
import type { Foo } from './other-file'
*/

And you can export types the same way:

// @flow
/*::
export type Foo = {| bar: string |}
*/

All 2 comments

You can definitely import types using the comment syntax:

// @flow
/*::
import type { Foo } from './other-file'
*/

And you can export types the same way:

// @flow
/*::
export type Foo = {| bar: string |}
*/

When I try this, I get 'Cannot resolve module'.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjj2000 picture mjj2000  路  3Comments

ghost picture ghost  路  3Comments

jamiebuilds picture jamiebuilds  路  3Comments

ctrlplusb picture ctrlplusb  路  3Comments

l2silver picture l2silver  路  3Comments