mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-06 17:29:08 +00:00
Merge pull request #7462 from chrootsu/lodash-bindKey
lodash: signatures of _.bindKey have been changed
This commit is contained in:
@@ -5372,24 +5372,87 @@ module TestBindAll {
|
||||
}
|
||||
}
|
||||
|
||||
var objectBindKey = {
|
||||
'name': 'moe',
|
||||
'greet': function (greeting: string) {
|
||||
return greeting + ' ' + this.name;
|
||||
// _.bindKey
|
||||
module TestBindKey {
|
||||
let object: {
|
||||
foo: (a: number, b: string) => boolean;
|
||||
}
|
||||
};
|
||||
|
||||
var funcBindKey: Function = _.bindKey(objectBindKey, 'greet', 'hi');
|
||||
funcBindKey();
|
||||
{
|
||||
type SampleResult = (a: number, b: string) => boolean;
|
||||
|
||||
objectBindKey.greet = function (greeting) {
|
||||
return greeting + ', ' + this.name + '!';
|
||||
};
|
||||
let result: SampleResult;
|
||||
|
||||
funcBindKey();
|
||||
result = _.bindKey<Object, SampleResult>(object, 'foo');
|
||||
result = _.bindKey<SampleResult>(object, 'foo');
|
||||
}
|
||||
|
||||
funcBindKey = _(objectBindKey).bindKey('greet', 'hi').value();
|
||||
funcBindKey();
|
||||
{
|
||||
type SampleResult = (b: string) => boolean;
|
||||
|
||||
let result: SampleResult;
|
||||
|
||||
result = _.bindKey<Object, SampleResult>(object, 'foo', 42);
|
||||
result = _.bindKey<SampleResult>(object, 'foo', 42);
|
||||
}
|
||||
|
||||
{
|
||||
type SampleResult = () => boolean;
|
||||
|
||||
let result: SampleResult;
|
||||
|
||||
result = _.bindKey<Object, SampleResult>(object, 'foo', 42, '');
|
||||
result = _.bindKey<SampleResult>(object, 'foo', 42, '');
|
||||
}
|
||||
|
||||
{
|
||||
type SampleResult = (a: number, b: string) => boolean;
|
||||
|
||||
let result: _.LoDashImplicitObjectWrapper<SampleResult>;
|
||||
|
||||
result = _(object).bindKey<SampleResult>('foo');
|
||||
}
|
||||
|
||||
{
|
||||
type SampleResult = (b: string) => boolean;
|
||||
|
||||
let result: _.LoDashImplicitObjectWrapper<SampleResult>;
|
||||
|
||||
result = _(object).bindKey<SampleResult>('foo', 42);
|
||||
}
|
||||
|
||||
{
|
||||
type SampleResult = () => boolean;
|
||||
|
||||
let result: _.LoDashImplicitObjectWrapper<SampleResult>;
|
||||
|
||||
result = _(object).bindKey<SampleResult>('foo', 42, '');
|
||||
}
|
||||
|
||||
{
|
||||
type SampleResult = (a: number, b: string) => boolean;
|
||||
|
||||
let result: _.LoDashExplicitObjectWrapper<SampleResult>;
|
||||
|
||||
result = _(object).chain().bindKey<SampleResult>('foo');
|
||||
}
|
||||
|
||||
{
|
||||
type SampleResult = (b: string) => boolean;
|
||||
|
||||
let result: _.LoDashExplicitObjectWrapper<SampleResult>;
|
||||
|
||||
result = _(object).chain().bindKey<SampleResult>('foo', 42);
|
||||
}
|
||||
|
||||
{
|
||||
type SampleResult = () => boolean;
|
||||
|
||||
let result: _.LoDashExplicitObjectWrapper<SampleResult>;
|
||||
|
||||
result = _(object).chain().bindKey<SampleResult>('foo', 42, '');
|
||||
}
|
||||
}
|
||||
|
||||
// _.compose
|
||||
module TestCompose {
|
||||
|
||||
65
lodash/lodash.d.ts
vendored
65
lodash/lodash.d.ts
vendored
@@ -8785,30 +8785,59 @@ declare module _ {
|
||||
}
|
||||
|
||||
//_.bindKey
|
||||
interface FunctionBindKey {
|
||||
placeholder: any;
|
||||
|
||||
<T extends Object, TResult extends Function>(
|
||||
object: T,
|
||||
key: any,
|
||||
...partials: any[]
|
||||
): TResult;
|
||||
|
||||
<TResult extends Function>(
|
||||
object: Object,
|
||||
key: any,
|
||||
...partials: any[]
|
||||
): TResult;
|
||||
}
|
||||
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Creates a function that, when called, invokes the method at object[key] and prepends any
|
||||
* additional bindKey arguments to those provided to the bound function. This method differs
|
||||
* from _.bind by allowing bound functions to reference methods that will be redefined or don't
|
||||
* yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern.
|
||||
* @param object The object the method belongs to.
|
||||
* @param key The key of the method.
|
||||
* @param args Arguments to be partially applied.
|
||||
* @return The new bound function.
|
||||
**/
|
||||
bindKey<T>(
|
||||
object: T,
|
||||
key: string,
|
||||
...args: any[]): Function;
|
||||
* Creates a function that invokes the method at object[key] and prepends any additional _.bindKey arguments
|
||||
* to those provided to the bound function.
|
||||
*
|
||||
* This method differs from _.bind by allowing bound functions to reference methods that may be redefined
|
||||
* or don’t yet exist. See Peter Michaux’s article for more details.
|
||||
*
|
||||
* The _.bindKey.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder
|
||||
* for partially applied arguments.
|
||||
*
|
||||
* @param object The object the method belongs to.
|
||||
* @param key The key of the method.
|
||||
* @param partials The arguments to be partially applied.
|
||||
* @return Returns the new bound function.
|
||||
*/
|
||||
bindKey: FunctionBindKey;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.bindKey
|
||||
**/
|
||||
bindKey(
|
||||
key: string,
|
||||
...args: any[]): LoDashImplicitObjectWrapper<Function>;
|
||||
* @see _.bindKey
|
||||
*/
|
||||
bindKey<TResult extends Function>(
|
||||
key: any,
|
||||
...partials: any[]
|
||||
): LoDashImplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.bindKey
|
||||
*/
|
||||
bindKey<TResult extends Function>(
|
||||
key: any,
|
||||
...partials: any[]
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.compose
|
||||
|
||||
Reference in New Issue
Block a user