Flow: Export x from './y' results in unexpected identifier error

Created on 11 Apr 2017  路  7Comments  路  Source: facebook/flow

If I write something like export a from './a' Flow gives me Unexpected identifier. Same if I write

import a from './a'
export a

Can I work around this?

I'm using 0.43

Most helpful comment

@Ai01 for me the solution was to write export {default as a} from './a'. So without the shorthand syntax. I haven't tried the other syntax since.

All 7 comments

I have since learned that export export a from './a' is sugar for export {default as a} from './a'. Flow understands this, so that solves it for me.

The new syntax should be supported at some point, once the proposal is mature enough?

But the fact that Flow trips over

import a from './a'
export a

... makes me assume there's also a bug involved.

l meet this problem too.Did you find some solutions ?@0x80

@Ai01 for me the solution was to write export {default as a} from './a'. So without the shorthand syntax. I haven't tried the other syntax since.

@0x80 l know. thank you very much.

is this a bug or not?

If there are multiple valid ways of writing the same thing and one is resulting in a type error then I'd consider this a bug yes. But I don't think the sugar syntax made it into the official standard yet, so in that sense it's simply not supported yet I assume.

It's not a bug guys. Just invalid syntax

import a from './a.js';

export {
  a
};
export const b = a;
export default a;

http://2ality.com/2014/09/es6-modules-final.html

Was this page helpful?
0 / 5 - 0 ratings