* Extract custom tests from tests/flow/
Approach:
1. Remove all .js files in tests/flow except .snap.js files.
2. Copy over all .js files from tests/ in the flow repo.
3. Go through the diff looking for deletions.
- It was easy to see which deletions were due to changes in the tests
due to updates in the flow repo.
- For the rest of the deletions, I used `git blame` to verify that
they had been added by us since the flow tests were copied over.
This makes tests/flow/ simply a copy of the tests from the flow repo,
making it easier to sync with the upstream flow tests in the future.
* Add a script for syncing the flow tests
* Sync the flow tests
87 lines
1.5 KiB
JavaScript
87 lines
1.5 KiB
JavaScript
import React from "react";
|
|
|
|
// initial state = None
|
|
React.createClass({
|
|
f() {
|
|
this.setState({ q: 0 });
|
|
},
|
|
g() {
|
|
(this.state.q: empty); // number ~> empty
|
|
}
|
|
});
|
|
|
|
// initial state = Some (exact & sealed) [lit]
|
|
React.createClass({
|
|
getInitialState() {
|
|
return { p: 0 };
|
|
},
|
|
f() {
|
|
this.setState({ q: 0 });
|
|
},
|
|
g() {
|
|
(this.state.q: empty); // number ~> empty
|
|
}
|
|
});
|
|
|
|
// initial state = Some (exact & sealed) [annot]
|
|
React.createClass({
|
|
getInitialState(): {| p: number |} {
|
|
return { p: 0 };
|
|
},
|
|
f() {
|
|
this.setState({ q: 0 });
|
|
},
|
|
g() {
|
|
(this.state.q: empty); // number ~> empty
|
|
}
|
|
});
|
|
|
|
// initial state = Some (inexact & sealed) [annot]
|
|
React.createClass({
|
|
getInitialState(): { p: number } {
|
|
return { p: 0 };
|
|
},
|
|
f() {
|
|
this.setState({ q: 0 }); // property `q` not found
|
|
},
|
|
g() {
|
|
(this.state.q: empty); // property `q` not found
|
|
}
|
|
});
|
|
|
|
// mixins = (exact & sealed) + (exact & sealed)
|
|
React.createClass({
|
|
mixins: [{
|
|
getInitialState() {
|
|
return { foo: 0 };
|
|
},
|
|
}],
|
|
getInitialState() {
|
|
return { bar: 0 };
|
|
},
|
|
f() {
|
|
this.setState({ baz: 0 });
|
|
},
|
|
g() {
|
|
(this.state.baz: empty); // number ~> empty
|
|
}
|
|
});
|
|
|
|
// mixins = (exact & sealed) + (inexact & sealed)
|
|
React.createClass({
|
|
mixins: [{
|
|
getInitialState(): { foo: number } {
|
|
return { foo: 0 };
|
|
},
|
|
}],
|
|
getInitialState() {
|
|
return { bar: 0 };
|
|
},
|
|
f() {
|
|
this.setState({ baz: 0 }); // property `baz` not found
|
|
},
|
|
g() {
|
|
(this.state.baz: empty); // property `baz` not found
|
|
}
|
|
});
|