1

Last version of lodash now has a few new functions. For example: https://lodash.com/docs#nth.

But lodash typings are for old version and hasn't those functions.

import _ = require('lodash');

How I can add declaration of those functions to _ object?

1 Answer 1

0

If you check your typings file you can see the basic LoDashStatic interface that you can extend:

import old = require('lodash')

interface LodashExt extends old.LoDashStatic {
    nth(n: Array<any>, i: number) : LodashExt
    // . . .
}

var _ = <LodashExt>old

_.add(1, 2)

_.nth(['a', 'b', 'c', 'd'], 2)

That should be enough for simple cases. You might want to put the above declarations to a module and just export your new _ value.

Sign up to request clarification or add additional context in comments.

1 Comment

Now I'm doing so. But I want without new variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.