babel / babylon

PSA: moved into babel/babel as @babel/parser -->

Home Page:https://github.com/babel/babel/tree/master/packages/babel-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should we allow Flowtype `import type` statements when `sourceType:script`?

loganfsmyth opened this issue · comments

We don't currently, but I'm thinking we should?

Flowtype doesn't seem to have a concept of sourceType. It just accepts import statements as normal statements, and doesn't worry about the grammar differences. I don't think we can go that far since Babel needs to follow to ECMA spec for parsing, but we could potentially allow import type {Foo} from ''; statements since import type is Flow-specific. We should double-check this with someone working on Flow ideally, but it seems to be the case from what I can tell.

Not sure is this is a concern for Typescript too.

Important since I'd like to nail down our approach to parsing in babel/babel#6242

@avikchaudhuri Do you happen to know if the Flow team has an opinion on this? My assumption is that Flow doesn't really care whether JS considers a file an ES6 module or a CommonJS module, but it'd be good to get an official confirmation so we don't risk affecting things further in the future.