Build error `no-undef` for flowtypes with class properties
See original GitHub issueCan 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:
npm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.7node -v
: v7.9.0npm -v
: 4.6.1
Then, specify:
- 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
- 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:
- Created 6 years ago
- Reactions:6
- Comments:16 (10 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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?
In the meantime, downgrading my own version to 3.19 cleared everything up.