flow-runtime
flow-runtime copied to clipboard
Fix type parameter references when assertions are disabled
Fixes #180.
Summary
- Avoid emitting local variable type cache declarations when neither assertions nor warnings are enabled.
- This prevents annotated-only output from referencing generic type parameters outside the
t.annotate(... t.function(...))callback where those parameters are defined. - Add a regression fixture for a generic function containing
let bar: Xwith assertions disabled.
Tests
TEST_FILTER='bugs/180-type-parameter-assert-false' yarn --cwd packages/babel-plugin-flow-runtime testyarn --cwd packages/babel-plugin-flow-runtime testyarn --cwd packages/babel-plugin-flow-runtime lint(exits 0; existing repo-wide jsx-a11y rule warnings remain)git diff --check