-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
version: 0.26.0
Bug description
This shows an ES2015/ES6/ES7 parsing bug - it will fail if there isn't a semicolon or static method after property declarations and before the first member method.
I first found in the test case that a constructor without a static method above it causes linting to fail on the first method with ^^^^^^^^^^^ Unexpected identifier. After suggestion, I tried adding a semicolon which proves the parsing error.
flowconfig
Same results with and without the following:
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
Test cases
https://github.com/rosskevin/react-flow-classes
Works (static method above)
// @flow
import React from 'react'
type DefaultProps = { x: 1 }
type Props = { x: number }
type State = { y: number }
class Foo extends React.Component {
props:Props
state:State
static defaultProps:DefaultProps
static bar ():void {}
constructor (props) {
super(props)
}
render () {
return <div>Hello World</div>
}
}Fails (no static method above)
// @flow
import React from 'react'
type DefaultProps = { x: 1 }
type Props = { x: number }
type State = { y: number }
class Foo extends React.Component {
props:Props
state:State
static defaultProps:DefaultProps
// fails without this static method above constructor
//static bar ():void {}
constructor (props) {
super(props)
}
render () {
return <div>Hello World</div>
}
}Works (a single semicolon)
// @flow
import React from 'react'
type DefaultProps = { x: 1 }
type Props = { x: number }
type State = { y: number }
class Foo extends React.Component {
props:Props
state:State
static defaultProps:DefaultProps;
// fails without this static method or semicolon above first constructor/member method
//static bar ():void {}
constructor (props) {
super(props)
}
render () {
return <div>Hello World</div>
}
}I proved the same in the sample repo with parameterized classes. May be related to #1171
cc @STRML
Expectation
All current failing classes in the test repo should succeed. I should not need to use any semicolons, and I don't need static methods above my constructor or member method.