For TS project having "moduleResolution": "NodeNext" in tsconfig.json and "type": "module" in package.json, TypeScript can't resolve to correct types.
import parseGitDiffExport from 'parse-git-diff';
// This expression is not callable.
// Type 'typeof import("node_modules/parse-git-diff/build/types/index")' has no call signatures.ts(2349)
parseGitDiffExport(diff);
This is how TypeScript's NodeNext mode interacts with CommonJS packages, seems the only fix is to put index.d.ts in both build/cjs and build/mjs and then remove "types" key in exports field.
For TS project having
"moduleResolution": "NodeNext"
intsconfig.json
and"type": "module"
inpackage.json
, TypeScript can't resolve to correct types.This is how TypeScript's
NodeNext
mode interacts with CommonJS packages, seems the only fix is to putindex.d.ts
in bothbuild/cjs
andbuild/mjs
and then remove"types"
key inexports
field.