diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244..345c0d787 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1665,8 +1665,15 @@ interface TestPickFn { } // _.set -result = <{ a: { b: { c: number; }}[]}>_.set({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c', 4); -result = <{ a: { b: { c: number; }}[]}>_({ 'a': [{ 'b': { 'c': 3 } }] }).set('a[0].b.c', 4).value(); +{ + let testSetObject: TResult; + let testSetPath: {toSting(): string}; + let result: TResult; + result = _.set(testSetObject, testSetPath, any); + result = _.set(testSetObject, [testSetPath], any); + result = _(testSetObject).set(testSetPath, any).value(); + result = _(testSetObject).set([testSetPath], any).value(); +} result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (r: number[], num: number) { num *= num; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710b..de6eeb8e3 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7543,23 +7543,28 @@ declare module _ { //_.set interface LoDashStatic { /** - * Sets the property value of path on object. If a portion of path does not exist it is created. + * Sets the property value of path on object. If a portion of path does not exist it’s created. + * * @param object The object to augment. * @param path The path of the property to set. * @param value The value to set. * @return Returns object. - **/ - set(object: T, - path: string|string[], - value: any): T; + */ + set( + object: T, + path: StringRepresentable|StringRepresentable[], + value: any + ): T; } interface LoDashObjectWrapper { /** * @see _.set - **/ - set(path: string|string[], - value: any): LoDashObjectWrapper; + */ + set( + path: StringRepresentable|StringRepresentable[], + value: any + ): LoDashObjectWrapper; } //_.transform @@ -8514,6 +8519,10 @@ declare module _ { interface Dictionary { [index: string]: T; } + + interface StringRepresentable { + toString(): string; + } } declare module "lodash" {