Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: type issue in ts@4.8+ with esm #3817

Closed
Mister-Hope opened this issue Nov 19, 2022 · 1 comment
Closed

Bug: type issue in ts@4.8+ with esm #3817

Mister-Hope opened this issue Nov 19, 2022 · 1 comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@Mister-Hope
Copy link
Contributor

Mister-Hope commented Nov 19, 2022

Description

The package is shipping esm files, but package.json is declaring "type": "commonjs" by mistake

So typescript will assume users are importing a commonjs module, so it will report issues with:

import memaid from "memaid";

memaid.someAPI(...args)

Saying the expression is not callable.

That's because a cjs module will have it's module.exports on default key, so:

import memaid from "memaid";

memaid.default.someAPI(...args)

is ok to typescript, but it's not acually working (because we do have esm modules using export default) and the default key does not exisit.

Steps to reproduce

Create project with "type": "module" and install mermaid. then ensure ts.config.json has target: "ESxxx", you will get issues mention above. (Does not need to use moduleResolution: NodeNext)

Screenshots

No response

Code Sample

No response

Setup

No response

Additional Context

No response

@Mister-Hope Mister-Hope added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Nov 19, 2022
@aloisklink
Copy link
Member

Potentially a duplicate of #3799

Although that one is explicitly about using dynamic import() in CommonJS, which is a bit more complicated in TypeScript.

@Mister-Hope Mister-Hope closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants