Skip to content

[Feature] Add types field to manifest for TypeScript support #6740

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

Closed
2 tasks done
grapgrap opened this issue Mar 26, 2025 · 0 comments
Closed
2 tasks done

[Feature] Add types field to manifest for TypeScript support #6740

grapgrap opened this issue Mar 26, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@grapgrap
Copy link

grapgrap commented Mar 26, 2025

  • I'd be willing to implement this feature (contributing guide)
  • This feature is important to have in this repository; a contrib plugin wouldn't do

Disclaimer: This content was written with the help of AI translation.

ref: #4834

Describe the user story

I want to make some util using @yarnpkg/parser.

But it did not have types field on manifest, I can't develop on typescript codebase.

Image

Describe the solution you'd like

According to this typescript docs, Package describe types field for type file.

// package.json
{
    "name": "my-package",
    "type": "module",
    "exports": {
        ".": {
            // Entry-point for `import "my-package"` in ESM
            "import": {
                // Where TypeScript will look.
                "types": "./types/esm/index.d.ts",
                // Where Node.js will look.
                "default": "./esm/index.js"
            },
            // Entry-point for `require("my-package") in CJS
            "require": {
                // Where TypeScript will look.
                "types": "./types/commonjs/index.d.cts",
                // Where Node.js will look.
                "default": "./commonjs/index.cjs"
            },
        }
    },
    // Fall-back for older versions of TypeScript
    "types": "./types/index.d.ts",
    // CJS fall-back for older versions of Node.js
    "main": "./commonjs/index.cjs"
}

Describe the drawbacks of your solution

The implementation is straightforward and follows TypeScript's official recommendations. There are no significant drawbacks as this change only adds type definitions without modifying existing functionality

Describe alternatives you've considered

@grapgrap grapgrap added the enhancement New feature or request label Mar 26, 2025
@grapgrap grapgrap changed the title [Feature] Need types field on manifest [Feature] Add types field to manifest for TypeScript support Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant