achievements-app / psn-api

A JavaScript library that lets you get trophy, user, and game data from the PlayStation Network.
https://psn-api.achievements.app
MIT License
263 stars 31 forks source link

fix: add type declaration to package exports #151

Closed Hartaithan closed 10 months ago

Hartaithan commented 10 months ago

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[bot] commented 10 months ago

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 commented 10 months ago

@all-contributors please add @Hartaithan for code

allcontributors[bot] commented 10 months ago

@wescopeland

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

github-actions[bot] commented 10 months ago

:tada: This PR is included in version 2.10.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: