Reputation: 51
So, in the docs of flow I usually see examples like these when it comes to importing types:
import type { someType } from './awesome'
import { somethingElse } from './awesome'
This is all fine and okay. However, I noticed that you can also do it like this:
import { somethingElse, type someType } from './awesome'
Is this considered to be a bad practice? If yes, why?
Thanks!
example for doc
Upvotes: 1
Views: 117
Reputation: 1444
So, there's been an issue plaguing our codebase for months that just got resolved due to this issue, which came up from using babel-plugin-rewire
with Flow and Babel. Essentially, doing the shorthand can trick Babel into thinking someType
is a binding, when it's not, and support for handling this case is supposed removed in Babel 7. (I haven't tried Babel 7 yet, can't comment there.) For our own sanity and future safety, we've changed everything to have import type
on a separate line.
Upvotes: 1