babel-plugin-flow-runtime references undefined type parameter names with assertions disabled
- Dominant language
- JavaScript
- Stars
- 797
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
[](https://oss.issuehunt.io/r/gajus/flow-runtime/issues/180)
This is a:
- [x] Bug Report
- [ ] Feature Request
- [ ] Question
- [ ] Other
Which concerns:
- [ ] flow-runtime
- [x] babel-plugin-flow-runtime
- [ ] flow-runtime-validators
- [ ] flow-runtime-mobx
- [ ] flow-config-parser
- [ ] The documentation website
---
### Code
```js
// @flow
function foo() {
let bar: X
}
```
### `.babelrc`
```
{
"presets": ["es2015"],
"plugins": [
"transform-decorators-legacy",
["flow-runtime", {"assert": false}]
]
}
```
### What is the current behaviour?
---
`X` is undefined in the output code below at `let _barType = X`:
```js
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?
---
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?
```
├── babel-core@6.26.0
├── babel-plugin-flow-runtime@0.15.0
├── babel-preset-es2015@6.24.0
```
---
IssueHunt Summary
### Backers (Total: $40.00)
- [ issuehunt](https://oss.issuehunt.io/u/issuehunt) ($40.00)
### Submitted pull Requests
- [#285 Fix assert false type parameter variables](https://oss.issuehunt.io/r/gajus/flow-runtime/pull/285)
- [#296 fix(plugin): avoid undefined type parameter references when assert=false](https://oss.issuehunt.io/r/gajus/flow-runtime/pull/296)
---
#### [Become a backer now!](https://oss.issuehunt.io/r/gajus/flow-runtime/issues/180)
#### [Or submit a pull request to get the deposits!](https://oss.issuehunt.io/r/gajus/flow-runtime/issues/180)
### Tips
- Checkout the [Issuehunt explorer](https://oss.issuehunt.io/r/gajus/flow-runtime/) to discover more funded issues.
- Need some help from other developers? [Add your repositories](https://oss.issuehunt.io/r/new) on IssueHunt to raise funds.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided babel-plugin-flow-runtime reproduction: transform the generic foo function using assert:false and inspect the generated code around the bar annotation. Compare the result with pull requests #285 and #296; done means the output no longer references X before it is defined or omits the unnecessary type variable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100