🌐
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 · 38,836,948 · 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
Discussions

[lodash @types/lodash] An issue with lodash typings causing TypeScript compilation error
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... More on github.com
🌐 github.com
5
June 13, 2023
Importing lodash into angular2 + typescript application
The only work around now it seems ... the lodash.d.ts in your typescript files. hopefully this will be fixed soon. if there is another work around for this i would like to hear it. ... the zip file would be great. But it looks like you are not using any module loader (like jspm or webpack) ? How are you loading Angular, via script tags? better post the html as well. I recommend you use webpack as module loader, see here an example -> github.com/jhade... More on stackoverflow.com
🌐 stackoverflow.com
Question - Importing single function with typescript, lodash, jest
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:... More on github.com
🌐 github.com
14
June 7, 2017
Provide better experience for using lodash in TypeScript
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 requi... More on github.com
🌐 github.com
10
July 19, 2022
🌐
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 › kawayiLinLin › typescript-lodash › tree › master
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%
🌐
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%
🌐
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
Find elsewhere
🌐
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
🌐
Lodash
lodash.com
Lodash
Lodash is released under the MIT license & supports modern environments.
🌐
GitHub
github.com › freewind-demos › typescript-use-lodash-es-demo
GitHub - freewind-demos/typescript-use-lodash-es-demo · GitHub
/Users/freewind/workspace/typescript-use-lodash-es-demo/node_modules/lodash-es/upperCase.js:1 (function (exports, require, module, __filename, __dirname) { import createCompounder from './_createCompounder.js'; ^^^^^^^^^^^^^^^^ SyntaxError: Unexpected identifier at new Script (vm.js:79:7)
Author   freewind-demos
🌐
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
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 › 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 › 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 › 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 › lodash › lodash
GitHub - lodash/lodash: A modern JavaScript utility library delivering modularity, performance, & extras. · GitHub
A modern JavaScript utility library delivering modularity, performance, & extras. - lodash/lodash
Starred by 61.6K users
Forked by 7.1K users
Languages   JavaScript 97.2% | HTML 2.3% | EJS 0.5%
🌐
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
🌐
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,475,682 · 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 › issues › 12394
4.14.38 lodash @typings break the global dependency handling in typescript 2.0 · Issue #12394 · DefinitelyTyped/DefinitelyTyped
November 1, 2016 - 4.14.38 lodash @typings break the global dependency handling in typescript 2.0#12394 · Copy link · ashubham · opened · on Nov 1, 2016 · Issue body actions · I tried using the latest @typings/lodash@4.14.38 module from the npmjs. I use lodash as a global in my app.
Author   ashubham