From c5d7c7a293ded80cb28b55a3e13249a9b8b52f49 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 7 Jan 2016 21:40:26 +0500 Subject: [PATCH] lodash: signatures of _.create have been changed --- lodash/lodash-tests.ts | 43 ++++++++++++++++++++++++++---------------- lodash/lodash.d.ts | 15 +++++++++++++-- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 77a20e2e2b..c60d303a70 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -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(prototype, properties); + result = _.create(prototype, properties); + } + + { + let result: _.LoDashImplicitObjectWrapper<{a: number; b: string}>; + + result = _(prototype).create(properties); + result = _(prototype).create(properties); + } + + { + let result: _.LoDashExplicitObjectWrapper<{a: number; b: string}>; + + result = _(prototype).chain().create(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 = _.create(testCreateProto); -result = _.create(testCreateProto, testCreateProps); -result = <{}>_(testCreateProto).create().value(); -result = <{}>_(testCreateProto).create(testCreateProps).value(); -result = _(testCreateProto).create().value(); -result = _(testCreateProto).create(testCreateProps).value(); // _.defaults module TestDefaults { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index c45ec90eea..421e5e1341 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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(prototype: Object, properties?: Object): TResult; + create( + prototype: T, + properties?: U + ): T & U; } interface LoDashImplicitObjectWrapper { /** * @see _.create */ - create(properties?: Object): LoDashImplicitObjectWrapper; + create(properties?: U): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.create + */ + create(properties?: U): LoDashExplicitObjectWrapper; } //_.defaults