lodash: signatures of _.create have been changed

This commit is contained in:
Ilya Mochalov
2016-01-07 21:44:13 +05:00
parent 81b951f1ac
commit c5d7c7a293
2 changed files with 40 additions and 18 deletions
+27 -16
View File
@@ -6774,23 +6774,34 @@ module TestAssign {
}
// _.create
interface TestCreateProto {
a: number;
module TestCreate {
type SampleProto = {a: number};
type SampleProps = {b: string};
let prototype: SampleProto;
let properties: SampleProps;
{
let result: {a: number; b: string};
result = _.create<SampleProto, SampleProps>(prototype, properties);
result = _.create(prototype, properties);
}
{
let result: _.LoDashImplicitObjectWrapper<{a: number; b: string}>;
result = _(prototype).create<SampleProps>(properties);
result = _(prototype).create(properties);
}
{
let result: _.LoDashExplicitObjectWrapper<{a: number; b: string}>;
result = _(prototype).chain().create<SampleProps>(properties);
result = _(prototype).chain().create(properties);
}
}
interface TestCreateProps {
b: string;
}
interface TestCreateTResult extends TestCreateProto, TestCreateProps {}
var testCreateProto: TestCreateProto;
var testCreateProps: TestCreateProps;
result = <{}>_.create(testCreateProto);
result = <{}>_.create(testCreateProto, testCreateProps);
result = <TestCreateProto>_.create<TestCreateProto>(testCreateProto);
result = <TestCreateTResult>_.create<TestCreateTResult>(testCreateProto, testCreateProps);
result = <{}>_(testCreateProto).create().value();
result = <{}>_(testCreateProto).create(testCreateProps).value();
result = <TestCreateProto>_(testCreateProto).create<TestCreateProto>().value();
result = <TestCreateTResult>_(testCreateProto).create<TestCreateTResult>(testCreateProps).value();
// _.defaults
module TestDefaults {
+13 -2
View File
@@ -11155,18 +11155,29 @@ declare module _ {
/**
* Creates an object that inherits from the given prototype object. If a properties object is provided its own
* enumerable properties are assigned to the created object.
*
* @param prototype The object to inherit from.
* @param properties The properties to assign to the object.
* @return Returns the new object.
*/
create<TResult extends {}>(prototype: Object, properties?: Object): TResult;
create<T extends Object, U extends Object>(
prototype: T,
properties?: U
): T & U;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.create
*/
create<TResult extends {}>(properties?: Object): LoDashImplicitObjectWrapper<TResult>;
create<U extends Object>(properties?: U): LoDashImplicitObjectWrapper<T & U>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.create
*/
create<U extends Object>(properties?: U): LoDashExplicitObjectWrapper<T & U>;
}
//_.defaults