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

fix: add type declaration to package exports #151

Merged
merged 1 commit into from
Oct 29, 2023

Conversation

Hartaithan
Copy link
Contributor

Resolves #145

I tested changes locally with npm link. Everything works fine.

Explanation from ChatGPT ¯_(ツ)_/¯

Adding types to package.json exports helps typescript find the type declarations of your package.

Before you added the "types" field to your "exports", TypeScript couldn’t find your type declarations through the "exports" field. But when you set moduleResolution to "node", TypeScript fell back to looking for an index.d.ts file in your module’s root directory. Since your type declarations were there, TypeScript was able to find them, and you didn’t see any error.

However, it’s generally better to specify all your module’s entry points (including type declarations) in the "exports" field. This way, you’re not relying on TypeScript’s fallback behavior, which might not work in all environments or future versions of TypeScript. Plus, it makes your package’s interface clearer to other developers. That’s why adding "types": "./dist/index.d.ts" to your package.json is a good solution.

@vercel
Copy link

vercel bot commented Oct 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
psn-api ❌ Failed (Inspect) Oct 28, 2023 1:18pm

@wescopeland
Copy link
Member

@all-contributors please add @Hartaithan for code

@allcontributors
Copy link
Contributor

@wescopeland

I've put up a pull request to add @Hartaithan! 🎉

@wescopeland wescopeland merged commit 6019d8d into achievements-app:main Oct 29, 2023
4 checks passed
@github-actions
Copy link

🎉 This PR is included in version 2.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Request to add "types" to package.json "exports" to fix "Not declaration file" related error messages
2 participants