Publish per format type declarations - #1192
manzoorwanijk wants to merge 1 commit into
Conversation
Resolves the `This expression is not callable` errors reported under node16 module resolution (steveukx#1191). - generate `dist/esm/index.d.ts` and `dist/cjs/index.d.ts` from the hand written typings, the CJS entry using `export =` to describe the callable `module.exports` - declare `types` per export condition so ESM consumers no longer resolve CJS declarations - add types for the deprecated `simple-git/promise` entry point - type check the ESM consumer package to cover both node16 conditions
🦋 Changeset detectedLatest commit: f5a2e51 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hello, thank you for the pull request. This change attempts to add additional support for the As this doesn't align with the future-state of the library I will close the PR. Please create a new Issue if you are having a problem that creates the need for such a change. |
|
What a pity!
But it's the problem with the root entrypoint as well. That fix for
I guess you didn't see the linked issue - #1191 |
|
The linked report shows that this is needed for node engines 16 and below - these are now fully end of life: https://nodejs.org/en/about/previous-releases#looking-for-the-latest-release-of-a-version-branch If this is an issue on node 22 or newer, please include an example of how the library is being imported with the error generated to give clarity to the reason for the change. |
It’s not the Node version, it’s the resolution algorithm used in Node 16 or greater. |
|
Sorry, I should have been clearer. "node16" here is TypeScript's
{ "compilerOptions": { "module": "nodenext", "strict": true, "noEmit": true } }
import simpleGit from 'simple-git';
const git = simpleGit();The same error happens for I'm happy to drop the |
Fixes #1191.
Every entry point resolved to the same CommonJS declarations, checked with arethetypeswrong.
Changes
typings/index.d.ts, the CJS one usingexport =to describe the callablemodule.exports.types, so ESM consumers stop resolving CJS declarations.Before:
simple-gitsimple-git/promiseAfter:
simple-gitsimple-git/promiseTesting
Type only tests in test-typescript-esm-consumer cover both node16 conditions and fail with
TS2349: This expression is not callablewithout this change.