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.

Incompatible types when using esm

See original GitHub issue

Currently the exposed types are not usable, when compiling typescript code as esm.

When importing this lib from esm, i need to write import * as simpleGit from 'simple-git';.

This will cause simpleGit.default to be the factory, which works. But the other enum types are not accessable as simpleGit.ResetMode, instead they are exported via simpleGit.default.ResetMode. Trying to use those will cause compilations issues.

https://github.com/renovatebot/renovate/pull/13184/files#diff-3c967a96825db779ae3fa03f549890aa993ea47b1b3326e800e7a582f1b5b351R43

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
steveukxcommented, Jan 2, 2022

The next release will contain #708 which enables the ES module imports in the same format as they would appear in TypeScript, ie:

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

You can follow the release in #709

1reaction
steveukxcommented, Jan 20, 2022

Hi, the latest version of simple-git is now available on npm, published with a major version bump as the packaging has changed to allow for both importing esm and requiring commonjs.

There are very few usage changes, so there should be no code change required in order to upgrade from v2.x to v3.x (unless you were using deprecated APIs that had been logging warnings to the console), or were importing from a path other than just simple-git.

There are notes for the release available in https://github.com/steveukx/git-js/tree/repo-v3.0.3#release-history and examples for ways to import the library in https://github.com/steveukx/git-js/tree/repo-v3.0.3#usage

Please do raise a new issue if you are having any problems using the new version, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exported types incompatible with ESM when using TypeScript ...
When importing rxjs in a project using TypeScript@next with the "module": "nodenext" (experimental ESM support) it fails to locate the ...
Read more >
How to Handle the Incompatible Types Error in Java - Rollbar
The Java incompatible types error happens when a value assigned to a variable or returned by a method is incompatible with the one...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Caveat: The ESM load hook and namespaced exports from CommonJS modules are incompatible. Attempting to use them together will result in an empty...
Read more >
Explicit ESM in Node.js with .mjs - DEV Community ‍ ‍
The straightforward answer to this is that having different file extensions allows you to be explicit in how you want to run your...
Read more >
ts-node - npm
Older versions of typescript are incompatible with @tsconfig/node16 . In those cases we will use an older default configuration. When in doubt, ...
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