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

Make "types" point to "dist/types/index.d.ts" in package.json #2306

Closed
9 of 10 tasks
jgoux opened this issue Aug 10, 2023 · 4 comments
Closed
9 of 10 tasks

Make "types" point to "dist/types/index.d.ts" in package.json #2306

jgoux opened this issue Aug 10, 2023 · 4 comments
Labels
s: awaiting more info Additional information are requested

Comments

@jgoux
Copy link

jgoux commented Aug 10, 2023

Pre-Checks

Describe the bug

Hello 👋,

Currently, the key "types" in your package.json is pointing to "index.d.ts" which doesn't exist.

The right location seems to be "dist/types/index.d.ts".

I noticed that by using https://github.com/lukasbach/monaco-editor-auto-typings and trying to load the types for Faker.

If there is no reason for it to point to "index.d.ts" I'll be happy to open a PR to fix it. 😄

Minimal reproduction code

No response

Additional Context

No response

Environment Info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 72.27 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.5.0 - ~/Library/pnpm/node
    npm: 9.5.1 - /opt/homebrew/bin/npm
    pnpm: 8.6.12 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 115.0.5790.170
    Safari: 16.5.2

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

pnpm

@jgoux jgoux added c: bug Something isn't working s: pending triage Pending Triage labels Aug 10, 2023
@ST-DDT
Copy link
Member

ST-DDT commented Aug 10, 2023

We do set it to the correct file in the typesVersions field:

faker/package.json

Lines 33 to 40 in 7f0daf3

"types": "index.d.ts",
"typesVersions": {
">=4.0": {
"*": [
"dist/types/*"
]
}
},

See also #1878, #1966

So AFAICT it's more like a bug in that other library?!
Or do you have more insight into the package.json magic?

@ST-DDT ST-DDT added s: awaiting more info Additional information are requested and removed s: pending triage Pending Triage c: bug Something isn't working labels Aug 10, 2023
@Shinigami92
Copy link
Member

We once tried to set it to dist/types/index.d.ts and this broke the whole package TS support
Since we reverted the change we had no more issues

What I learned in the meantime is, that cjs and mjs can be supported with .d.cts and .d.mts files directly placed beside their .cjs or .mjs files. But then we would need to duplicate every types file and we actually don't want that.
Before we do that, we might go full esm-only and start to ignore such niche cases.

@jgoux
Copy link
Author

jgoux commented Aug 14, 2023

We once tried to set it to dist/types/index.d.ts and this broke the whole package TS support Since we reverted the change we had no more issues

What I learned in the meantime is, that cjs and mjs can be supported with .d.cts and .d.mts files directly placed beside their .cjs or .mjs files. But then we would need to duplicate every types file and we actually don't want that. Before we do that, we might go full esm-only and start to ignore such niche cases.

I tried to test faker against arethetypeswrong but unfortunately it can't resolve wildcard subpaths 😄: https://arethetypeswrong.github.io/?p=%40faker-js%2Ffaker%406.3.1

I think @andrewbranch could help you figure out what the proper setup for your types should be and why setting it to dist/types/index.d.ts didn't work!

In the meantime, I will try to send a PR to https://github.com/lukasbach/monaco-editor-auto-typings to be able to parse typesVersions. 👍

@ST-DDT
Copy link
Member

ST-DDT commented Nov 15, 2023

It looks like there is currently no todo on our side here.

@ST-DDT ST-DDT closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: awaiting more info Additional information are requested
Projects
None yet
Development

No branches or pull requests

3 participants