* 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
32 lines
722 B
JavaScript
32 lines
722 B
JavaScript
// @flow
|
|
|
|
/**
|
|
* Fields annotated with a generic should assume a type once the type param
|
|
* is instantiated.
|
|
*/
|
|
class ClassAnnotated<T> {
|
|
p: T;
|
|
static p: T;
|
|
}
|
|
|
|
var o1 = new ClassAnnotated();
|
|
o1.p = 42;
|
|
(o1.p: number);
|
|
(o1.p: string); // Error: number ~> string
|
|
ClassAnnotated.p = 42;
|
|
(ClassAnnotated.p: number);
|
|
(ClassAnnotated.p: string); // Error: number ~> string
|
|
|
|
|
|
/**
|
|
* It's always an error to initialized a generically-typed field with an
|
|
* expression of any type other than the generic itself.
|
|
*/
|
|
class ClassGenericInitialized<T, U> {
|
|
invalid: T = 42; // Error: number ~> Generic<T>
|
|
valid: T = ((42:any):T);
|
|
|
|
static invalid: T = 42; // Error: number ~> Generic<T>
|
|
static valid: T = ((42:any):T);
|
|
}
|