question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support flow experimental.const_params=true

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS High Sierra 10.13 Node: 6.11.2 Yarn: 1.1.0 npm: 3.10.10 Watchman: 4.7.0 Xcode: Xcode 9.0 Build version 9A235 Android Studio: Not Found

Packages: (wanted => installed) react: 16.0.0-alpha.12 => 16.0.0-alpha.12 react-native: ^0.48.4 => 0.48.4

Steps to Reproduce

(Write your steps here:)

  1. Create a new react-native app with create-react-native-app
  2. yarn add --dev flow-bin@^0.49.1 (same version specified in .flowconfig)
  3. Add experimental.const_params=true under [options] in .flowconfig
  4. ./node_modules/.bin/flow

Expected Behavior

No errors.

(Write what you thought would happen.)

Actual Behavior

$ flow
node_modules/fbjs/lib/UnicodeBidi.js.flow:90
 90:   fallback = fallback || UnicodeBidiDirection.NEUTRAL;
       ^^^^^^^^ fallback. const param cannot be reassigned (see experimental.const_params=true in .flowconfig)
 89: function resolveBlockDir(str: string, fallback: ?BidiDirection): BidiDirection {
                                           ^^^^^^^^^^^^^^^^^^^^^^^^ const param fallback

node_modules/fbjs/lib/UnicodeBidi.js.flow:92
 92:     return fallback;
                ^^^^^^^^ null. This type is incompatible with the expected return type of
 89: function resolveBlockDir(str: string, fallback: ?BidiDirection): BidiDirection {
                                                                      ^^^^^^^^^^^^^ string enum

…[removed for brevity]…

... 88 more errors (only 50 out of 138 errors displayed)
To see all errors, re-run Flow with --show-all-errors

Reproducible Demo

https://github.com/ckknight/ReactNative-const_params-repro

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ckknightcommented, Oct 6, 2017

This also affects react-native@0.49.0

0reactions
kelsetcommented, Mar 19, 2019

👋 there - this issue is still technically “not fixed”, for the reason Eli explained above.

Basically every instance similar to this in the main codebase

function foo(arg) {
  arg += 2;
  console.log(arg);
}

would need to be changed to

function foo(arg) {
  let localArg = arg;
  localArg += 2;
  console.log(localArg);
}

There is a codemod Eli worked on -> https://github.com/cpojer/js-codemod/pull/85 which would help a lot in automating this process, but there is a 1% cases in which it would conflict.

So, all in all, there is a lot of work related to “code hygiene” - we’d love to see some PRs to help with this effort but it’s really low prior right now. So I’m going to close it as there are more important tasks to focus on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support - FLOW-3D
Our support staff is comprised of experienced engineers who understand the needs and problems facing users in competitive professional environments.
Read more >
Experiment #6: Orifice and Free Jet Flow - Mavs Open Press
Flow measurement by an orifice is based on the application of Bernoulli's equation, which states that a relationship exists between the pressure of...
Read more >
Flow Experiment Site Database — NCEAS Working Group
Use this form to enter information about a site where streamflow and/or stage have been manipulated at a dam, diversion structure, or other...
Read more >
Experimental Aerodynamics & Flow Visualization - Sites@Duke
The goal of this project is to serve as an assistance tool while learning these concepts, by visualizing those aerodynamic phenomenons, such as:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found