flow-runtime icon indicating copy to clipboard operation
flow-runtime copied to clipboard

babel plugin adds annotations even when no @flow pragma is present

Open niieani opened this issue 8 years ago • 2 comments

This is a:

  • [x] Bug Report

Which concerns:

  • [x] babel-plugin-flow-runtime

What is the current behaviour?

Currently, a file that contains type annotations, but no @flow pragma, will still get the flow-runtime annotations. This is a problem, especially since you cannot write @flow-runtime ignore, without enabling flow itself at the same time 🤓

(Flow looks for @flow, not ^@flow$, and @flow-runtime satisfies the regex).


What is the expected behaviour?

The babel plugin should not annotate files without the @flow pragma.


Which package versions are you using?

0.10.0

niieani avatar Apr 07 '17 09:04 niieani

(Flow looks for @flow, not ^@flow$, and @flow-runtime satisfies the regex).

nasty!

phpnode avatar Apr 07 '17 13:04 phpnode

On a second thought, it might be good to make it configurable: whether we want to:

  • opt-in by specifying @flow-runtime (or another pragma)
  • execute always, even when @flow pragma is not present, opt-out of it via @flow-runtime disable (or perhaps to not collide with flow the pragma could be changed?)
  • execute only when @flow is enabled opt-out of it via @flow-runtime disable or another pragma.

Not sure what's the best solution here, but I can see cases where the combination of using @flow-runtime, while at the same time NOT using @flow also might make sense.

In essence, we'd need to support all permutations.

niieani avatar Apr 07 '17 17:04 niieani