» npm install @types/lodash
Factsheet
How to import lodash in a typescript library package?
A Typescript-first alternative to Lodash/Underscore
[@types/lodash] Issue with lodash typings causing TypeScript compilation error
ts node - How to use lodash-es in typescript correctly? - Stack Overflow
EDIT: I forgot to put a question mark at the end of the title. Whoops!
I understand that both libraries have "@types/..." that can easily be downloaded. Still, some corners of the library would have been better designed if they were initially built in Typescript rather than tacking on a.d.ts file later.
I am starting a new project and would like to know if any alternatives have been developed recently.
You can load types from here:
npm install --save-dev @types/lodash-es
And use it like:
import { camelCase } from "lodash-es"
ts-node compiles .ts files as they are loaded. It doesn't touch .js files; either they must already be in a form understood by Node.js (e.g., no ES6 import statements) or you must use a separate mechanism to transform them, such as the @babel/register require hook (essentially the same thing that is used by babel-node). You would still need to configure @babel/register not to ignore node_modules, as described in the other answer. The advice from the other answer to just use lodash instead of lodash-es is good.