facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.07k stars 1.86k forks source link

[0.55] regression - react synthetic events (try flow bug only?) #4966

Open rosskevin opened 7 years ago

rosskevin commented 7 years ago

SyntheticEvents appear to not be included in 55, but works in 54.1 and lower

Test code (linked above):

import * as React from 'react';

type Props = {
  onChange?: (value: ?string) => void
};

class MyComponent extends React.Component<Props> {
  handleClick = (e: SyntheticEvent<>) => {
    const {onChange} = this.props
    if (onChange) {
      onChange('foo clicked')
    }
  }

  render() {
    return <div onClick={this.handleClick}>foo</div>;
  }
}

<MyComponent />;
8:   handleClick = (e: SyntheticEvent<>) => {
                       ^ identifier `SyntheticEvent`. Could not resolve name

This seems like a regression, because these SyntheticEvents are still in the libdef https://github.com/facebook/flow/blob/v0.55.0/lib/react-dom.js

and recommended to be used by https://flow.org/en/docs/react/events/

Here is an exact 55 try flow of the docs example, which also works in 54.1 and lower.

I actually came to report a different issue and when trying to boil down the test case, perhaps this is the root cause.

rosskevin commented 7 years ago

There is also the possibility that this could just be a regression with the Try flow tool as well.

Mathspy commented 5 years ago

@goodmind This is indeed a TryFlow regression (tested locally with CRA and it works fine), I know you and someone else are working on a new TryFlow editor so feel free to label this based on its relevance and importance today If it's relevant I might try to solve this