question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`simpleGit` is not callable in TypeScript ESM

See original GitHub issue

Thanks 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

  1. I created a TypeScript project that outputs an ESM module based on @sindresorhusrecommendations.

  2. I tested this using typescript@4.7.3 and typescript@4.3.5; same results.

  3. I used simple-git@3.7.1.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tukusejssirscommented, Jun 28, 2022

The issues relating to redis and @types/cache-manager-redis-store are unexpected - they’re not in the dependency graph for the simple-git workspace.

Of course! For some reason I didn’t read the error. Sorry for the report of this error.

I am happy to add a named export so you would switch to:

import { simpleGit, SimpleGit } from 'simple-git';

Yeah, thanks, it fixes the issue. 🙏

Just a note: wouldn’t it be better to rename simpleGit to something else? Its name is same as SimpleGit (apart from the casing). Also, don’t you think it should have capital initial letter?

1reaction
steveukxcommented, Jun 25, 2022

You can now use version 3.10.0 in your ESM TypeScript application, but please be advised that you will need to import the named simpleGit export rather than relying on the default export.

(Default exports remain available for backward compatibility with any application still using CJS).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found