Do not strip flow import type declarations
See original GitHub issueThe latest version of Babel 7 strips out flow import type
declarations by default. They used to be included with earlier versions of Babel 7 and 6. Whilst it makes sense to remove them, is there an easy way to keep them and treat them as regular imports, as the app I’m working on uses flow-runtime and relies on the types to work.
Is there an existing plugin that can do this, or do I need to write my own? At the moment I’m replacing import type
with import
as a build step before running babel, but if feels like there should be a way to do it all within Babel.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Flowtype – how to export and import types? - Stack Overflow
If I fail to put // @flow in Module A , the compiler treats NumberAlias as any , and fails to ... import...
Read more >Utility Types - JavaScript. Flow
The resulting type from this operation will be an object type containing A 's own properties that are not own properties in B...
Read more >babel/plugin-transform-flow-strip-types
Setting this to true will only strip annotations and declarations from files that contain the // @flow directive. It will also throw errors...
Read more >Documentation - TypeScript 3.8
import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there's no remnant of...
Read more >Migrating 500k lines of Flow code to TypeScript - Medium
A look into migrating a large codebase from one type checking tool to another. Foreword. This article is not meant to justify why...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nicolo-ribaudo thanks for the info - after a bit more investigating I realised the issue was with flow-runtime and the plugin babel-plugin-flow-runtime. There’s a fix in the latest version which has resolved the issue if it helps anyone else: https://github.com/gajus/flow-runtime/issues/254
Babel by default doesn’t transform your code, you are unknowingly enabling the flow transform somewhere.
You can post the output of
BABEL_SHOW_CONFIG_FOR
(use your build command instead ofnpm start
) if you need help figuring out where it’s enabled.