Flow: Export all types from file

Created on 9 Feb 2018  Â·  10Comments  Â·  Source: facebook/flow

We've got a lot of types in our current project and I'd love to organise them in separate files, while importing them from a single point of entry (like you would with regular js in some cases). That's why I'd love to do this:

// types/index.js
export * from './a';
export * from './b';
export * from './c';

Flow-wise this seems to work! But running this code in a (in this case react-native) project, this doesn't seem to be stripped away and it failes on a syntax error. Am I doing this wrong? Is this an undocumented feature that I'm not (yet) supposed to use?

All 10 comments

@Jpunt It's just javascript. Possibly you don't transpile something with babel.

Are you saying that my example should work already? It does work properly when I re-export each type by hand (eq export type {Something} from ‘./a’), so I don’t see why my transpiler config would allow the one but not the other.. :thinking:

By the way, just found out that doing the same thing from within a nested file does work! Could this be a bug?

@Jpunt Show more detailed example, it's not clear for me what is changed

I really don't know what happend before the weekend, but it seems to be working fine 🤔 sorry to waste your time!

I'm having the same issue in a project made with create-react-app. I would love for this to work, but for now I'll probably just revert to

export type {Type1, Type2) from './filename'

@dannyharding10 For now you can use export * from 'file' which is works perfectly.

Thanks for your quick response! The problem was using export type * from './file' instead of export * from './file'. I needed to omit the word type

@dannyharding10 Yep, this syntax does not exist and I don't think ever will. What's the problem with export * from?

Sorry that's what I meant, removing the word type fixed the problem for me!

@TrySound did this PR included the usage of export type *?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cubika picture cubika  Â·  3Comments

mmollaverdi picture mmollaverdi  Â·  3Comments

jamiebuilds picture jamiebuilds  Â·  3Comments

l2silver picture l2silver  Â·  3Comments

funtaps picture funtaps  Â·  3Comments