Files
test-repo/tests/flow/function/bind.js
T

28 lines
648 B
JavaScript
Raw Normal View History

2016-12-23 19:31:38 +00:00
// @flow
let tests = [
function(x: (a: string, b: string) => void) {
let y = x.bind(x, 'foo');
y('bar'); // ok
y(123); // error, number !~> string
},
2017-04-08 16:52:38 +02:00
// callable objects
function(x: { (a: string, b: string): void }) {
let y = x.bind(x, 'foo');
y('bar'); // ok
y(123); // error, number !~> string
},
// non-callable objects
function(x: { a: string }) {
x.bind(x, 'foo'); // error
},
// callable objects with overridden `bind` method
function(x: {(a: string, b: string): void, bind(a: string): void}) {
(x.bind('foo'): void); // ok
(x.bind(123): void); // error, number !~> string
},
2016-12-23 19:31:38 +00:00
];