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.

Build error `no-undef` for flowtypes with class properties

See original GitHub issue

Can you reproduce the problem with npm 4.x?

Yes

Description

An error when running yarn run build occurs if I add a class property with a type to a react component. E.g.

interface MyType {
  what?: string;
}

// works fine
var status: MyType = {};
console.log(status);

class App extends Component {
  // no-undef build error
  state: MyType = {};
  render() {
...

Expected behavior

✨ Done in 11.24s.

Actual behavior

./src/App.js
  Line 16:  'state' is not defined  no-undef

Search for the keywords to learn more about each error.

error Command failed with exit code 1.

Note that yarn run flow raises no issue. So I’m guessing it’s an eslint problem but there’s no way to tell from the build output. Would be nice if the errors were tagged with their source (vs code does this in the problems panel).

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected): react-scripts@1.0.7
  2. node -v: v7.9.0
  3. npm -v: 4.6.1

Then, specify:

  1. Operating system: macOS 10.12.5 (16F73), uname -a: Darwin yuv 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
  2. Browser and version: This is a command line build issue

Reproducible Demo

https://github.com/ubershmekel/create-react-app-flowtypes

Related to

https://github.com/kitze/custom-react-scripts/issues/12 https://github.com/facebookincubator/create-react-app/pull/567

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

17reactions
chrisdrackettcommented, Oct 23, 2017

@gaearon I just updated to the newest CRA and this seems to have popped up again for me. I’m wondering now that CRA uses eslint 4 is this is a bug now? Is anyone else running into this?

4reactions
JeffreyATWcommented, Jun 26, 2017

In the meantime, downgrading my own version to 3.19 cleared everything up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`'Props' is not defined. (no-undef)` when using react-native ...
I'm adding Flow to my react-native project. Following the examples at https://flow.org/en/docs/react/components/ I've updated by ...
Read more >
eslint-plugin-flowtype - npm
This plugin exports a recommended configuration that enforces Flow type good practices. To enable this configuration use the extends property in ...
Read more >
Flow – JavaScript Type Checker | Object Computing, Inc.
Types specify the conditions under which code such as a function or class will run. In static programming languages, type errors are detected...
Read more >
Secret Flow Types - Medium
Secret Flow Types ... The result type is an object type, which contains only properties, ... class C {}const a1:$Supertype<B> = new A;...
Read more >
typeerror: cannot read properties of undefined jasmine - You.com ...
But on couple of re-try the tests gets successful and the build gets success ... angular Jasmine karma error TypeError: Cannot read properties...
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