Closed benasher44 closed 9 months ago
Maybe the issue is that the types are correct, but they're lying? If that's the case, feel free to close.
I should add that they only fail when running node on ESM output. This import works fine with CJS output (only tested CJS using module set to node, not nodenext)
Here's a simple program that illustrates the issue:
import _, { random } from "lodash";
console.log(_.random());
console.log(random());
This compiles fine with tsc --module NodeNext file.ts
, but the import fails at runtime (am now wondering if I've discovered a bug with ts emit).
Okay so I think I just stumbled upon microsoft/TypeScript#54018. Would it be reasonable to use cjs-module-lexer in this package, and then flag the types with 👺 ?
Duplicate of #35? 😉
Oh wow nice!
I'm not sure 100% what's going on (lodash's js style of exporting is not written in the most standard way — somewhat difficult to parse out in my head), but attw claims lodash's types are correct.
However, named lodash imports fail at runtime in node ESM. For example:
This will fail with: