182 lines
3.3 KiB
Plaintext
182 lines
3.3 KiB
Plaintext
exports[`test A.js 1`] = `
|
|
"/**
|
|
* @flow
|
|
*/
|
|
|
|
class Foo {
|
|
}
|
|
|
|
class Bar {
|
|
}
|
|
|
|
module.exports = {
|
|
Foo: Foo,
|
|
Bar: Bar
|
|
};
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/**
|
|
* @flow
|
|
*/
|
|
|
|
class Foo {}
|
|
|
|
class Bar {}
|
|
|
|
module.exports = { Foo: Foo, Bar: Bar };
|
|
"
|
|
`;
|
|
|
|
exports[`test bad_shadowing.js 1`] = `
|
|
"/**
|
|
* @flow
|
|
*/
|
|
|
|
import typeof A from \"./A.js\";
|
|
import type {Foo, Bar as Baz} from \"./A.js\";
|
|
|
|
type duck = {
|
|
quack: () => string;
|
|
}
|
|
|
|
// These string types should confict with the imported types
|
|
var A: string = \"Hello\";
|
|
var Foo: string = \"Goodbye\";
|
|
var Baz: string = \"Go away please\";
|
|
|
|
// This string type should conflict with the typedef
|
|
var duck: string = \"quack\";
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/**
|
|
* @flow
|
|
*/
|
|
|
|
import typeof A from \"./A.js\";
|
|
import type { Foo, Bar as Baz } from \"./A.js\";
|
|
|
|
type duck = { quack(): string };
|
|
|
|
// These string types should confict with the imported types
|
|
var A: string = \"Hello\";
|
|
var Foo: string = \"Goodbye\";
|
|
var Baz: string = \"Go away please\";
|
|
|
|
// This string type should conflict with the typedef
|
|
var duck: string = \"quack\";
|
|
"
|
|
`;
|
|
|
|
exports[`test good_shadowing.js 1`] = `
|
|
"/**
|
|
* @flow
|
|
*/
|
|
|
|
import typeof A from \"./A.js\";
|
|
import type {Foo, Bar as Baz} from \"./A.js\";
|
|
|
|
var A = require(\'./A.js\');
|
|
var Foo = A.Foo;
|
|
var Baz = A.Bar;
|
|
|
|
// errors in prev block leave type bindings in place, so these are errors
|
|
var m = A;
|
|
var n = Foo;
|
|
var o = Baz;
|
|
|
|
// errors from value positions only
|
|
var a: Foo = new Foo();
|
|
var b: Foo = new A.Foo();
|
|
(new A.Bar(): Baz);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/**
|
|
* @flow
|
|
*/
|
|
|
|
import typeof A from \"./A.js\";
|
|
import type { Foo, Bar as Baz } from \"./A.js\";
|
|
|
|
var A = require(\"./A.js\");
|
|
var Foo = A.Foo;
|
|
var Baz = A.Bar;
|
|
|
|
// errors in prev block leave type bindings in place, so these are errors
|
|
var m = A;
|
|
var n = Foo;
|
|
var o = Baz;
|
|
|
|
// errors from value positions only
|
|
var a: Foo = new Foo();
|
|
var b: Foo = new A.Foo();
|
|
(new A.Bar(): Baz);
|
|
"
|
|
`;
|
|
|
|
exports[`test import_type.js 1`] = `
|
|
"/**
|
|
* @flow
|
|
*/
|
|
|
|
import typeof A from \"./A.js\";
|
|
import type {Foo, Bar as Baz} from \"./A.js\";
|
|
|
|
var actualA = require(\'./A.js\');
|
|
|
|
// You can\'t use it as an identifier
|
|
var m = A;
|
|
var n = Foo;
|
|
var o = Baz;
|
|
|
|
// But using it in a type should still work
|
|
var a: Foo = new actualA.Foo();
|
|
(new actualA.Bar(): Baz);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/**
|
|
* @flow
|
|
*/
|
|
|
|
import typeof A from \"./A.js\";
|
|
import type { Foo, Bar as Baz } from \"./A.js\";
|
|
|
|
var actualA = require(\"./A.js\");
|
|
|
|
// You can\'t use it as an identifier
|
|
var m = A;
|
|
var n = Foo;
|
|
var o = Baz;
|
|
|
|
// But using it in a type should still work
|
|
var a: Foo = new actualA.Foo();
|
|
(new actualA.Bar(): Baz);
|
|
"
|
|
`;
|
|
|
|
exports[`test type_alias.js 1`] = `
|
|
"/**
|
|
* @flow
|
|
*/
|
|
|
|
type Foo = number;
|
|
|
|
// You can\'t use it as an identifier
|
|
var x = Foo;
|
|
|
|
// But using it in a type should still work
|
|
var a: Foo = 123;
|
|
var b: Array<Foo> = [123];
|
|
type c = Foo;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/**
|
|
* @flow
|
|
*/
|
|
|
|
type Foo = number;
|
|
|
|
// You can\'t use it as an identifier
|
|
var x = Foo;
|
|
|
|
// But using it in a type should still work
|
|
var a: Foo = 123;
|
|
var b: Array<Foo> = [ 123 ];
|
|
type c = Foo;
|
|
"
|
|
`;
|