bind.ts
Function.prototype.bind with typings for TypeScript
Function#bind
is untyped in TypeScript (in v3.0 at least, cf: #212).
It always returns any
.
// bar is `any`!;// okbar20; // 'hello: 30'// should be a type error, but actually allowed...bar'anything';
bind.ts
is a workaround for this issue.
; // bar is `(b: number) => string`;// okbar20; // 'hello: 30'// error!bar'anything';
Note: TypeScript v3.0 introduces generic rest parameters. It's helpful but cannot solve this issue completely and the type definition of Function#bind
in TypeScript core is not changed.
Requirement
bind.ts v2 requires TypeScript v3.0+. For TypeScript v2.x, use bind.ts v1.
Limitation
The maximum number of params of bind()
is 5.
License
MIT License: Teppei Sato <teppeis@gmail.com>