Merge pull request #7529 from chrootsu/lodash-create

lodash: signatures of _.create have been changed
This commit is contained in:
Masahiro Wakame
2016-01-11 22:40:24 +09:00
2 changed files with 40 additions and 18 deletions

View File

@@ -7505,23 +7505,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 {

15
lodash/lodash.d.ts vendored
View File

@@ -11756,18 +11756,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