bind.ts
Advanced tools
Comparing version 1.1.4 to 2.0.0
@@ -1,22 +0,7 @@ | ||
declare function bind<R, T>(f: (this: T) => R, thisArg: T): () => R; | ||
declare function bind<R, T, A>(f: (this: T, _0: A) => R, thisArg: T): (_0: A) => R; | ||
declare function bind<R, T, A>(f: (this: T, _0: A) => R, thisArg: T, _0: A): () => R; | ||
declare function bind<R, T, A, B>(f: (this: T, _0: A, _1: B) => R, thisArg: T): (_0: A, _1: B) => R; | ||
declare function bind<R, T, A, B>(f: (this: T, _0: A, _1: B) => R, thisArg: T, _0: A): (_1: B) => R; | ||
declare function bind<R, T, A, B>(f: (this: T, _0: A, _1: B) => R, thisArg: T, _0: A, _1: B): () => R; | ||
declare function bind<R, T, A, B, C>(f: (this: T, _0: A, _1: B, _2: C) => R, thisArg: T): (_0: A, _1: B, _2: C) => R; | ||
declare function bind<R, T, A, B, C>(f: (this: T, _0: A, _1: B, _2: C) => R, thisArg: T, _0: A): (_1: B, _2: C) => R; | ||
declare function bind<R, T, A, B, C>(f: (this: T, _0: A, _1: B, _2: C) => R, thisArg: T, _0: A, _1: B): (_2: C) => R; | ||
declare function bind<R, T, A, B, C>(f: (this: T, _0: A, _1: B, _2: C) => R, thisArg: T, _0: A, _1: B, _2: C): () => R; | ||
declare function bind<R, T, A, B, C, D>(f: (this: T, _0: A, _1: B, _2: C, _3: D) => R, thisArg: T): (_0: A, _1: B, _2: C, _3: D) => R; | ||
declare function bind<R, T, A, B, C, D>(f: (this: T, _0: A, _1: B, _2: C, _3: D) => R, thisArg: T, _0: A): (_1: B, _2: C, _3: D) => R; | ||
declare function bind<R, T, A, B, C, D>(f: (this: T, _0: A, _1: B, _2: C, _3: D) => R, thisArg: T, _0: A, _1: B): (_2: C, _3: D) => R; | ||
declare function bind<R, T, A, B, C, D>(f: (this: T, _0: A, _1: B, _2: C, _3: D) => R, thisArg: T, _0: A, _1: B, _2: C): (_3: D) => R; | ||
declare function bind<R, T, A, B, C, D>(f: (this: T, _0: A, _1: B, _2: C, _3: D) => R, thisArg: T, _0: A, _1: B, _2: C, _3: D): () => R; | ||
declare function bind<R, T, A, B, C, D, E>(f: (this: T, _0: A, _1: B, _2: C, _3: D, _4: E) => R, thisArg: T): (_0: A, _1: B, _2: C, _3: D, _4: E) => R; | ||
declare function bind<R, T, A, B, C, D, E>(f: (this: T, _0: A, _1: B, _2: C, _3: D, _4: E) => R, thisArg: T, _0: A): (_1: B, _2: C, _3: D, _4: E) => R; | ||
declare function bind<R, T, A, B, C, D, E>(f: (this: T, _0: A, _1: B, _2: C, _3: D, _4: E) => R, thisArg: T, _0: A, _1: B): (_2: C, _3: D, _4: E) => R; | ||
declare function bind<R, T, A, B, C, D, E>(f: (this: T, _0: A, _1: B, _2: C, _3: D, _4: E) => R, thisArg: T, _0: A, _1: B, _2: C): (_3: D, _4: E) => R; | ||
declare function bind<R, T, A, B, C, D, E>(f: (this: T, _0: A, _1: B, _2: C, _3: D, _4: E) => R, thisArg: T, _0: A, _1: B, _2: C, _3: D): (_4: E) => R; | ||
declare function bind<R, T, A, B, C, D, E>(f: (this: T, _0: A, _1: B, _2: C, _3: D, _4: E) => R, thisArg: T, _0: A, _1: B, _2: C, _3: D, _4: E): () => R; | ||
declare function bind<T, V, R extends any[]>(f: (this: T, ...args: R) => V, thisArg: T): (...args: R) => V; | ||
declare function bind<T, V, R extends any[], A0>(f: (this: T, a0: A0, ...args: R) => V, thisArg: T, a0: A0): (...args: R) => V; | ||
declare function bind<T, V, R extends any[], A0, A1>(f: (this: T, a0: A0, a1: A1, ...args: R) => V, thisArg: T, a0: A0, a1: A1): (...args: R) => V; | ||
declare function bind<T, V, R extends any[], A0, A1, A2>(f: (this: T, a0: A0, a1: A1, a2: A2, ...args: R) => V, thisArg: T, a0: A0, a1: A1, a2: A2): (...args: R) => V; | ||
declare function bind<T, V, R extends any[], A0, A1, A2, A3>(f: (this: T, a0: A0, a1: A1, a2: A2, a3: A3, ...args: R) => V, thisArg: T, a0: A0, a1: A1, a2: A2, a3: A3): (...args: R) => V; | ||
declare function bind<T, V, R extends any[], A0, A1, A2, A3, A4>(f: (this: T, a0: A0, a1: A1, a2: A2, a3: A3, a4: A4, ...args: R) => V, thisArg: T, a0: A0, a1: A1, a2: A2, a3: A3, a4: A4): (...args: R) => V; | ||
export default bind; |
{ | ||
"name": "bind.ts", | ||
"description": "Function.prototype.bind with typings for TypeScript", | ||
"version": "1.1.4", | ||
"version": "2.0.0", | ||
"author": "Teppei Sato <teppeis@gmail.com>", | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"main": "lib/index.js", | ||
@@ -21,8 +24,8 @@ "types": "lib/index.d.ts", | ||
"devDependencies": { | ||
"@types/mocha": "^2.2.41", | ||
"@types/node": "^7.0.14", | ||
"mocha": "^3.3.0", | ||
"npm-run-all": "^4.0.2", | ||
"rimraf": "^2.6.1", | ||
"typescript": "^2.3.2" | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^6.0.117", | ||
"mocha": "^5.2.0", | ||
"npm-run-all": "^4.1.3", | ||
"rimraf": "^2.6.2", | ||
"typescript": "^3.0.3" | ||
}, | ||
@@ -29,0 +32,0 @@ "homepage": "https://github.com/teppeis/bind.ts#readme", |
@@ -1,3 +0,3 @@ | ||
bind.ts | ||
==== | ||
# bind.ts | ||
Function.prototype.bind with typings for TypeScript | ||
@@ -11,8 +11,8 @@ | ||
`Function#bind` is untyped in TypeScript (in v2.3 at least, cf: [#212](https://github.com/Microsoft/TypeScript/issues/212)). | ||
TypeScript always returns `any` for `bind()`. | ||
`Function#bind` is untyped in TypeScript (in v3.0 at least, cf: [#212](https://github.com/Microsoft/TypeScript/issues/212)). | ||
It always returns `any`. | ||
```typescript | ||
function foo(a: number, b: number): string { | ||
return `${this.msg}: ${a + b}`; | ||
return `${this.msg}: ${a + b}`; | ||
} | ||
@@ -40,5 +40,12 @@ // bar is `any`! | ||
Note: TypeScript v3.0 introduces [generic rest parameters](https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#generic-rest-parameters). It's helpful but cannot solve this issue completely and [the type definition of `Function#bind` in TypeScript core](https://github.com/Microsoft/TypeScript/blob/v3.0.3/src/lib/es5.d.ts#L273) is not changed. | ||
## Requirement | ||
bind.ts v2 requires TypeScript v3.0+. | ||
For TypeScript v2.x, use bind.ts v1. | ||
## Limitation | ||
The maximum number of arguments of the function is ***5***. | ||
The maximum number of params of `bind()` is **_5_**. | ||
@@ -52,13 +59,7 @@ ## License | ||
[npm-downloads-image]: https://img.shields.io/npm/dm/bind.ts.svg | ||
[travis-image]: https://img.shields.io/travis/teppeis/bind.ts/master.svg | ||
[travis-url]: https://travis-ci.org/teppeis/bind.ts | ||
[circleci-image]: https://circleci.com/gh/teppeis/bind.ts.svg?style=svg | ||
[circleci-image]: https://circleci.com/gh/teppeis/bind.ts.svg?style=shield | ||
[circleci-url]: https://circleci.com/gh/teppeis/bind.ts | ||
[appveyor-image]: https://ci.appveyor.com/api/projects/status/ | ||
[appveyor-url]: https://ci.appveyor.com/project/teppeis/bind.ts/branch/master | ||
[deps-image]: https://img.shields.io/david/teppeis/bind.ts.svg | ||
[deps-url]: https://david-dm.org/teppeis/bind.ts | ||
[node-version]: https://img.shields.io/badge/Node.js%20support-v4,v6,v7-brightgreen.svg | ||
[coverage-image]: https://img.shields.io/coveralls/teppeis/bind.ts/master.svg | ||
[coverage-url]: https://coveralls.io/github/teppeis/bind.ts?branch=master | ||
[node-version]: https://img.shields.io/badge/Node.js%20support-v6,v8,v10-brightgreen.svg | ||
[license]: https://img.shields.io/npm/l/bind.ts.svg |
63
4947
37