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

babel-plugin-flow-runtime references undefined type parameter names with assertions disabled

Open jedwards1211 opened this issue 7 years ago • 1 comments

Issuehunt badges

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

// @flow

function foo<X>() {
  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:

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?

├── [email protected] 
├── [email protected] 
├── [email protected] 

IssueHunt Summary

Backers (Total: $40.00)

Become a backer now!

Or submit a pull request to get the deposits!

Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

jedwards1211 avatar Dec 20 '17 19:12 jedwards1211

@issuehunt has funded $40.00 to this issue.


issuehunt-oss[bot] avatar Jul 24 '19 13:07 issuehunt-oss[bot]