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.

Flow error: Cannot use conditional as a computed property

See original GitHub issue

I’m seeing these errors, using Flow 0.123.0. Also seeing them on the version of flow used by this repo if I paste the code into try flow.

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/react-window/src/createGridComponent.js:615:12

Cannot use conditional [1] as a computed property. Computed properties may only be primitive literal values, but
conditional [1] is a union. Can you add a literal type annotation to conditional [1]? See
https://flow.org/en/docs/types/literals/ for more information on literal types.

     612│       } else {
     613│         itemStyleCache[key] = style = {
     614│           position: 'absolute',
 [1] 615│           [direction === 'rtl' ? 'right' : 'left']: getColumnOffset(
     616│             this.props,
     617│             columnIndex,
     618│             this._instanceProps


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/react-window/src/createListComponent.js:471:12

Cannot use conditional [1] as a computed property. Computed properties may only be primitive literal values, but
conditional [1] is a union. Can you add a literal type annotation to conditional [1]? See
https://flow.org/en/docs/types/literals/ for more information on literal types.

     468│
     469│         itemStyleCache[index] = style = {
     470│           position: 'absolute',
 [1] 471│           [direction === 'rtl' ? 'right' : 'left']: isHorizontal ? offset : 0,
     472│           top: !isHorizontal ? offset : 0,
     473│           height: !isHorizontal ? size : '100%',
     474│           width: isHorizontal ? size : '100%',

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

2reactions
cstoddartcommented, Aug 10, 2020

@jedwards1211 I had this same error. Finally fixed it this morning by upgrading flow-bin to 0.129.0

So it turns out this was only a temporary solution. I intended to put up a PR with a fix, but when I pulled down the repo I noticed the necessary changes were already there.

@bvaughn Can you make a release with the latest changes?

In the mean time, I can confirm that "react-window": "bvaughn/react-window#master" in my package.json is working well for me. 👍

0reactions
cstoddartcommented, Oct 27, 2020

Definitely not a solution I’m happy to suggest either way. I actually ended up pulling the code I needed from this repo and put it directly into my codebase. Kind of a pain but it’s not a ton of code 🤷‍♂️

Read more comments on GitHub >

github_iconTop Results From Across the Web

'computed property' may only be literal values in flow?
Flow complains about the last line, saying cannot use MyA as a computed property, computed properties must be primitive literal values.
Read more >
Spreads: Common Errors & Fixes - Flow - Medium
Instead of inferring a 10k large object union, Flow will emit an error saying that you cannot use a union as a computed...
Read more >
setter - JavaScript - MDN Web Docs
The set syntax binds an object property to a function to be called when there is an attempt to set that property. It...
Read more >
Computed Properties - Vue.js
A computed property will only re-evaluate when some of its reactive dependencies have changed. This means as long as author.books has not changed,...
Read more >
Asynchronous Flow | Kotlin Documentation
builder block can suspend. The simple function is no longer marked with a suspend modifier. Values are emitted from the flow using an ......
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