-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
/* @flow */
type T = { foo: string } & number[];
function foo(): T {
let x = [];
x.foo = "";
return x; // Can't create an inhabitant
}
function foo(x: T): void {
// $ExpectError x.foo is a string, not a number
(x.foo : number);
// $ExpectError x.length is a number (from Array.prototype.length), not a string
(x.length : string);
// $ExpectError x[0] is a number, not a string
(x[0] : string);
}
test.js:7
7: x.foo = "";
^^^ property `foo`. Property not found in
7: x.foo = "";
^^^^^ Array
test.js:8
8: return x; // Can't create an inhabitant
^ empty array literal. This type is incompatible with
3: type T = { foo: string } & number[];
^^^^^^^^^^^^^^^ object type
test.js:18
18: // $ExpectError x[0] is a number, not a string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error suppressing comment. Unused suppression
ajhyndman, aeneasr, fc-io, pkaminski, sdougbrown and 4 more