Closed lshearer closed 7 years ago
Hi sorry for the delay, this project is now deprecated in favour of flow-runtime which aims for full flow compatibility. flow-runtime has a slightly different method of specifying pragmas, see here - https://codemix.github.io/flow-runtime/#/docs/pragmas
When using the
only
option to opt files in to type checking, files that have no leading comments will not be skipped. This can result in runtime errors.E.g., given the following files:
index.js
doSomething.js
(has no leading comments)MyType.js
and a
.babelrc
with a plugin section including:When running the transpiled
index.js
file, you'll encounter an error likeTypeError: MyType is not a function
. This is becausedoSomething.js
was processed for type checking and resulted in something semantically similar tobut
MyType.js
was not processed for type checking, so it resulted in something likeThis results in a failed validation call because the imported
MyType
is undefined, whereas it would be a validation method had it been processed as well.The problem appears to be that one of the checks to enforce the
only
option is skipped if the file doesn't have any leading comments, resulting in that file getting processed, even though it does not contain a// @typecheck production
(or similar) pragma.Although files with flow types are likely to contain at least a
// @flow
leading comment, this is not required and is still a valid case which can lead to very confusing errors.