Files
test-repo/tests/flow/more_react/App.react.js
T
Christopher Chedeau 3375cfe605 Move tests around (#454)
* new_tests

* move_all_clobbered_tests

* remove all the tests that no longer exist

* re-run flow tests

* Move all the flow tests to tests/flow and prettier to tests/

* Move prettier tests to their own folders

* Add jsfmt files

* run prettier snapshot tests
2017-01-24 14:35:37 -08:00

44 lines
707 B
JavaScript

/**
* @providesModule App.react
* @jsx React.DOM
*/
var React = require('react');
// expect args to be strings
function foo(p:string,q:string):string { return p+q; }
var App = React.createClass({
getDefaultProps: function(): { y: string } {
return {y:""}; // infer props.y: string
},
getInitialState: function() {
return {z:0}; // infer state.z: number
},
handler: function() {
this.setState({z:42}); // ok
},
render: function() {
var x = this.props.x;
var y = this.props.y;
var z = this.state.z;
//this.state;
return (
<div>
{foo(x,y)}
{foo(z,x)} // error, since z: number
</div>
);
}
});
module.exports = App;