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

Incorrect ESM types #2482

Closed
petertonysmith94 opened this issue Jun 7, 2024 · 6 comments
Closed

Incorrect ESM types #2482

petertonysmith94 opened this issue Jun 7, 2024 · 6 comments
Assignees
Labels
bug Issue is a bug chore Issue is a chore

Comments

@petertonysmith94
Copy link
Contributor

petertonysmith94 commented Jun 7, 2024

As part of #1776, we fixed the runtime issues that were being thrown for ESM based packages. However, the side note of incorrect types as specified by AreTheTypeWrong.

Screenshot 2024-12-03 at 14 49 11
@petertonysmith94 petertonysmith94 added the chore Issue is a chore label Jun 7, 2024
@arboleya arboleya added this to the 1—caterpillar milestone Jun 9, 2024
@arboleya arboleya added the p0 label Jun 9, 2024
@arboleya arboleya modified the milestones: 1.0 caterpillar, 0.x post-launch Jun 12, 2024
@arboleya arboleya added p1 and removed p0 labels Jul 19, 2024
@arboleya arboleya removed this from the 0.x post-launch milestone Jul 19, 2024
@arboleya arboleya added bug Issue is a bug chore Issue is a chore and removed chore Issue is a chore labels Jul 20, 2024
@arboleya arboleya removed the p1 label Aug 2, 2024
@arboleya arboleya added temp-p1 and removed temp-M labels Sep 7, 2024
@arboleya arboleya added the temp:notion label Sep 8, 2024 — with Linear
@arboleya arboleya added the temp-linear label Sep 8, 2024 — with Linear
@petertonysmith94
Copy link
Contributor Author

Pretty good resource on ESM related requirements

@danielbate danielbate self-assigned this Dec 3, 2024
@danielbate
Copy link
Member

I went down a bit of an ESM rabbit hole earlier with #2567 so I'll have a dig here...

@danielbate
Copy link
Member

Just done a new check on arethetypeswrong and we have resolved some problems, only the masqueraded ESM now so going to update the description.

@petertonysmith94
Copy link
Contributor Author

petertonysmith94 commented Dec 3, 2024

There is a CLI utility for testing the packages locally.

I think the following PR might be helpful.

I wouldn't linger too long upon this one, as no end-consumers have brought this up and I remember this one being a rabbit hole :)

Currently

From what I remember - the issue with our distribution is that we share the types between both ESM and CJS:

└─ dist
    ├── index.d.ts
    ├── index.d.ts.map
    ├── index.js
    ├── index.js.map
    ├── index.mjs
    └── index.mjs.map

Expected

So then the types aren't shared between them.

└─ dist
    ├─ cjs
        ├─ index.d.ts
        ├─ index.d.ts.map
        ├─ index.cjs
        └─ index.cjs.map
    └─ mjs
        ├─ index.d.ts
        ├─ index.d.ts.map
        ├─ index.mjs
        └─ index.mjs.map

@danielbate
Copy link
Member

danielbate commented Dec 3, 2024

Ty, I will check those out, I think I am reading something similar. But agreed, I won't lose too much time on it.

@danielbate
Copy link
Member

danielbate commented Dec 4, 2024

Okay so for this as @petertonysmith94 mentions we need to separate our distribution files between CJS and ESM. The expected way for this though is to create a *.d.mts file for ESM typings. Using a single dist seems to be a common problem for projects shipping using tsup. There's a couple open issues right now for tsup to provide more config around dist files for ESM. I think we keep an eye on these issues (1, 2) to see how things develop and me may be able to fix this through tsup. But shipping both CJS and ESM from a single package seems like a very prevalent issue in the TS lib world.

I'm going to close this for now as we haven't had any reports since #1776 and our AreTheTypeWrong report has improved since then. We only have the masqueraded types issue, which seems more nuanced and up for discussion.

@danielbate danielbate closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is a bug chore Issue is a chore
Projects
None yet
Development

No branches or pull requests

3 participants