🌐
npm
npmjs.com › package › @types › lodash
@types/lodash - npm
February 23, 2026 - npm i @types/lodash · github.com/DefinitelyTyped/DefinitelyTyped · github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lodash · 39,104,387 · 4.17.24 · MIT · 870 kB · 707 · a month ago · types · Analyze security with SocketCheck bundle sizeView package healthExplore dependencies ·
      » npm install @types/lodash
    
🌐
GitHub
github.com › DefinitelyTyped › DefinitelyTyped › tree › master › types › lodash
DefinitelyTyped/types/lodash at master · DefinitelyTyped/DefinitelyTyped
The repository for high quality TypeScript type definitions. - DefinitelyTyped/types/lodash at master · DefinitelyTyped/DefinitelyTyped
Author   DefinitelyTyped
🌐
Kawayilinlin
kawayilinlin.github.io › typescript-lodash
TypeScript-Lodash
import { string } from "typescript-lodash" type IString = "今天很高兴" type TypeExample = string.Split<IString, ""> // 得到 type TypeResult = ["今", "天", "很", "高", "兴"]
🌐
GitHub
github.com › lodash › lodash › issues › 4635
Lodash type errors when build with typescript in NodeJS · Issue #4635 · lodash/lodash
January 23, 2020 - Hello, I am using lodash in nodeJS express app, but when I build the project, I get type errors in terminal of lodash methods. src/api/customer/customer.controller.ts:225:75 - error TS2345: Argument of type 'unknown[]' is not assignable ...
Author   ishaqueahmed-mev
🌐
GitHub
github.com › DefinitelyTyped › DefinitelyTyped › blob › master › types › lodash › index.d.ts
DefinitelyTyped/types/lodash/index.d.ts at master · DefinitelyTyped/DefinitelyTyped
The repository for high quality TypeScript type definitions. - DefinitelyTyped/types/lodash/index.d.ts at master · DefinitelyTyped/DefinitelyTyped
Author   DefinitelyTyped
🌐
GitHub
github.com › kawayiLinLin › typescript-lodash
GitHub - kawayiLinLin/typescript-lodash: A typescript tools lib · GitHub
A typescript tools lib. Contribute to kawayiLinLin/typescript-lodash development by creating an account on GitHub.
Starred by 73 users
Forked by 5 users
Languages   TypeScript 94.6% | JavaScript 5.4%
🌐
Lodash
lodash.com
Lodash
Lodash is released under the MIT license & supports modern environments.
🌐
GitHub
github.com › lodash › lodash › issues › 3192
Question - Importing single function with typescript, lodash, jest · Issue #3192 · lodash/lodash
June 7, 2017 - I am writing a library using typescript, jest and lodash and I would like to ship it as 2 modules - commonjs (for webpack 1) and with es2015 modules (for webpack 2 with tree-shaking). What i tried: import { cloneDeep } from 'lodash'; inc...
Author   vojty
🌐
GitHub
github.com › taoqf › lodash-ts
GitHub - taoqf/lodash-ts: Simple functional toolkit
Simple functional toolkit. Contribute to taoqf/lodash-ts development by creating an account on GitHub.
Starred by 9 users
Forked by 2 users
Languages   TypeScript 99.5% | JavaScript 0.5% | TypeScript 99.5% | JavaScript 0.5%
Find elsewhere
🌐
GitHub
github.com › denoland › deno › issues › 15240
Provide better experience for using lodash in TypeScript · Issue #15240 · denoland/deno
July 19, 2022 - In lots of TypeScript interface .d.ts files around the internet, you see this sort of pattern: import _ = require("../index"); Unfortunately, Deno is unable to read these because it requires file extensions on imported modules (it expects to see ../index.d.ts). This means that lots of typings are unusable in Deno, while perfectly good in most other engines. Because the typings for lodash do this, I had an incredibly hard time finding a way to include lodash with correct typings in Deno.
Author   stabai
🌐
GitHub
github.com › microsoft › TypeScript › issues › 54638
[lodash @types/lodash] An issue with lodash typings causing TypeScript compilation error · Issue #54638 · microsoft/TypeScript
June 13, 2023 - Bug Report Description I encountered TypeScript compilation errors related to the @types/lodash package. The errors occur in the common.d.ts file of the @types/lodash package during the build proce...
Author   nikbarseghyan
🌐
GitHub
github.com › DefinitelyTyped › DefinitelyTyped › issues › 63022
GitHub · Where software is built
November 1, 2022 - @types/lodash@4.14.187 compilation issue#63022 · Copy link · LeVraiSylvain · opened · on Nov 1, 2022 · Issue body actions · Can't compile with version 4.14.187 · It works well with 4.14.186 · Environment · node v14.18.1 · tsconfig : in attachment ·
Author   LeVraiSylvain
Top answer
1 of 16
508

Here is how to do this as of Typescript 2.0: (tsd and typings are being deprecated in favor of the following):

$ npm install --save lodash

# This is the new bit here: 
$ npm install --save-dev @types/lodash

Then, in your .ts file:

Either:

import * as _ from "lodash";

Or (as suggested by @Naitik):

import _ from "lodash";

I'm not positive what the difference is. We use and prefer the first syntax. However, some report that the first syntax doesn't work for them, and someone else has commented that the latter syntax is incompatible with lazy loaded webpack modules. YMMV.

Edit on Feb 27th, 2017:

According to @Koert below, import * as _ from "lodash"; is the only working syntax as of Typescript 2.2.1, lodash 4.17.4, and @types/lodash 4.14.53. He says that the other suggested import syntax gives the error "has no default export".

2 of 16
70

Update September 26, 2016:

As @Taytay's answer says, instead of the 'typings' installations that we used a few months ago, we can now use:

npm install --save @types/lodash

Here are some additional references supporting that answer:

  • https://www.npmjs.com/package/@types/lodash
  • TypeScript typings in NPM @types org packages

If still using the typings installation, see the comments below (by others) regarding '''--ambient''' and '''--global'''.

Also, in the new Quick Start, config is no longer in index.html; it's now in systemjs.config.ts (if using SystemJS).

Original Answer:

This worked on my mac (after installing Angular 2 as per Quick Start):

sudo npm install typings --global
npm install lodash --save 
typings install lodash --ambient --save

You will find various files affected, e.g.

  • /typings/main.d.ts
  • /typings.json
  • /package.json

Angular 2 Quickstart uses System.js, so I added 'map' to the config in index.html as follows:

System.config({
    packages: {
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    },
    map: {
      lodash: 'node_modules/lodash/lodash.js'
    }
  });

Then in my .ts code I was able to do:

import _ from 'lodash';

console.log('lodash version:', _.VERSION);

Edits from mid-2016:

As @tibbus mentions, in some contexts, you need:

import * as _ from 'lodash';

If starting from angular2-seed, and if you don't want to import every time, you can skip the map and import steps and just uncomment the lodash line in tools/config/project.config.ts.

To get my tests working with lodash, I also had to add a line to the files array in karma.conf.js:

'node_modules/lodash/lodash.js',
🌐
GitHub
github.com › frontapp › types-lodash
GitHub - frontapp/types-lodash
Contribute to frontapp/types-lodash development by creating an account on GitHub.
Author   frontapp
🌐
GitHub
github.com › dimaxweb › lodash-typescript-examples
GitHub - dimaxweb/lodash-typescript-examples
Contribute to dimaxweb/lodash-typescript-examples development by creating an account on GitHub.
Author   dimaxweb
🌐
GitHub
github.com › TypeStrong › typedoc › issues › 688
@types/lodash 4.14.74 isn't compatible with TypeScript 2.7.1, update to later version · Issue #688 · TypeStrong/typedoc
January 31, 2018 - There are more details and example video here: Referenced Issue: alexjoverm/typescript-library-starter#172 · There are many later version of @type/lodash available that likely have fixed this issue. Since it's such a popular library I'm sure someone else ran into this. I think fix would be to simply update the dependency of @types/lodash to a later version which has the fix tested against TS 2.7.1 then publish new 0.9.1 version of this package so consuming projects will be unblocked.
Author   mattmazzola
🌐
GitHub
github.com › topics › lodash
lodash · GitHub Topics · GitHub
Lodash-like, dependency-free utilities for native ES6 promises. nodejs javascript promises typescript lodash blend dependency-free
🌐
npm
npmjs.com › package › @types › lodash-es
@types/lodash-es - npm
November 21, 2023 - npm i @types/lodash-es · github.com/DefinitelyTyped/DefinitelyTyped · github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lodash-es · 5,462,584 · 4.17.12 · MIT · 71.9 kB · 329 · 2 years ago · types · Analyze security with SocketCheck bundle sizeView package healthExplore dependencies ·
      » npm install @types/lodash-es
    
🌐
GitHub
github.com › DefinitelyTyped › DefinitelyTyped › blob › master › types › lodash › fp.d.ts
DefinitelyTyped/types/lodash/fp.d.ts at master · DefinitelyTyped/DefinitelyTyped
The repository for high quality TypeScript type definitions. - DefinitelyTyped/types/lodash/fp.d.ts at master · DefinitelyTyped/DefinitelyTyped
Author   DefinitelyTyped