Do you want to work on this issue?
You can request for a bounty in order to promote it!
babel-plugin-flow-runtime references undefined type parameter names with assertions disabled #180
jedwards1211 posted onGitHub
<!-- Thanks for using flow-runtime! To help us address your issue quickly please provide as much information about the problem you're facing, or the feature you'd like adding. -->
This is a:
- Bug Report
- Feature Request
- Question
- Other
Which concerns:
- flow-runtime
- babel-plugin-flow-runtime
- flow-runtime-validators
- flow-runtime-mobx
- flow-config-parser
- The documentation website
Code
// @flow
function foo<X>() {
let bar: X
}
.babelrc
{
"presets": ["es2015"],
"plugins": [
"transform-decorators-legacy",
["flow-runtime", {"assert": false}]
]
}
What is the current behaviour?
<!-- If this is a bug report or question, please include example code wherever possible. If your code is private and you can't share it, please create a sanitized version which reproduces the issue. You may find the online demo useful for this: https://codemix.github.io/flow-runtime/#/try NOTE: It is extremely difficult to fix bugs without examples! -->
X
is undefined in the output code below at let _barType = X
:
import t from "flow-runtime";
function foo() {
let _barType = X,
bar;
}
t.annotate(foo, t.function(_fn => {
const X = _fn.typeParameter("X");
return [];
}));
What is the expected behaviour?
<!-- Please describe what you'd expect to happen under these circumstances. If you are describing a bug in the babel plugin, please indicate the output you'd expect it to produce. -->
Either babel-plugin-flow-runtime
doesn't create _barType
, or it inserts const X = t.typeParameter("X")
above let _barType
it despite the "assert": false
in the plugin options.
Which package versions are you using?
<!-- If this is a bug, which version(s) of the affected package(s) are you using? If you're describing a bug specific to an environment, like a certain browser or node version, please include that information here too. -->
āāā babel-core@6.26.0
āāā babel-plugin-flow-runtime@0.15.0
āāā babel-preset-es2015@6.24.0