yeonjuan / parse-git-diff

parse git diff
MIT License
28 stars 3 forks source link

Type resolve error in Node ESM mode #29

Closed otakustay closed 7 months ago

otakustay commented 8 months ago

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.

yeonjuan commented 8 months ago

@otakustay Thank you for reporting the issue. I can reproduce the error. This is clearly a bug and should be fixed!.

yeonjuan commented 7 months ago

@otakustay It's fixed and released in v0.0.15! Thanks!