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

exports_types_should_be_first: Should be the first in the object as required by TypeScript. #583

Open
doug-wade opened this issue Jan 10, 2024 · 0 comments
Labels

Comments

@doug-wade
Copy link
Owner

doug-wade commented Jan 10, 2024

We're getting two related errors from publint:

The types is not exported. Consider adding pkg.exports["."].import.types to be compatible with TypeScript's "moduleResolution": "bundler" compiler option. Note that you cannot use "./dist/types/index.d.ts" because it has a mismatching format. Instead, you can duplicate the file and use the .mts extension, e.g. pkg.exports["."].import.types: "./dist/types/index.d.mts" (More info)

And

Should be the first in the object as required by TypeScript. (More info)

From the docs:

Ensure "types" condition to be the first. The TypeScript docs recommends so, but it's also because the "exports" field is order-based.

For example, a scenario where both the "types" and "import" condition could be active, "types" should be first so that it matches and returns a .d.ts file, rather than a .js file from the "import" condition.

See the linter results:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant