`simpleGit` is not callable in TypeScript ESM
See original GitHub issueThanks for this awesome utility!
I tried to use it in an TypeScript ESM module, but running simpleGit()
gets me an error from TypeScript:
import simpleGit, {SimpleGit} from 'simple-git'
const git: SimpleGit = simpleGit()
// Output:
error TS2349: This expression is not callable.
Type 'typeof import("$repo_root/node_modules/simple-git/dist/typings/index")' has no call signatures.
When I ignore the error (using @ts-ignore:next-line
), it runs just fine, therefore I suspect it is an error in the type definition or something
Notes
-
I created a TypeScript project that outputs an ESM module based on @sindresorhus’ recommendations.
-
I tested this using
typescript@4.7.3
andtypescript@4.3.5
; same results. -
I used
simple-git@3.7.1
.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Typescript error This expression is not callable. #2404 - GitHub
The fix is export = fastify and export = fastifyCookie and so on. I see it has been suggested to use the "esModuleInterop":...
Read more >This expression is not callable. Type 'typeof import(...)' has no ...
Typescript error when using require - This expression is not callable. Type 'typeof import(...)' has no call signatures.ts(2349).
Read more >PyCharm 2022.1 (221.5080.212 build) Release Notes
No subsystem Bug PY‑52880
Code Insight Bug PY‑52346
Bug PY‑52169
Bug PY‑49663
Read more >Third Party Software | Confluent
Confluent is building the foundational platform for data in motion so any organization can innovate and win in a digital-first world.
Read more >pnpm-lock.yaml · varlet/varlet-ui - Gitee.com
simple-git -hooks: 2.8.0. stylelint: 13.13.1. typescript: ... deprecated: Chokidar 2 does not receive security updates since 2019. ... is-callable: 1.2.4.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Of course! For some reason I didn’t read the error. Sorry for the report of this error.
Yeah, thanks, it fixes the issue. 🙏
Just a note: wouldn’t it be better to rename
simpleGit
to something else? Its name is same asSimpleGit
(apart from the casing). Also, don’t you think it should have capital initial letter?You can now use version
3.10.0
in your ESM TypeScript application, but please be advised that you will need to import the namedsimpleGit
export rather than relying on the default export.(Default exports remain available for backward compatibility with any application still using CJS).