Add TypeScript type declarations to exports field in package.json #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request updates the
package.json
file by adding TypeScript type declarations to the"exports"
field. Previously, TypeScript users faced issues due to missing type information, which caused errors during development. This change ensures proper type resolution for both Node.js and browser environments, improving the package’s usability for TypeScript developers.Changes
"exports"
field to include"types"
entries:"require": { "types": "./dist/index-node.d.ts", "default": "./dist/index-node.cjs" }
"import": { "types": "./dist/index-node.d.ts", "default": "./dist/index-node.esm.js" }
"require": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.esm.js" }
dist
directory (e.g.,index-node.d.ts
andindex.d.ts
), as shown in the project’s directory structure.Why This Matters
TypeScript is widely used, and without proper type declarations, developers couldn’t fully utilize the package in typed projects. This fix eliminates those errors and enhances the developer experience.
Testing
@aislamov/diffusers.js
. The type errors are gone, and the package works correctly in both Node.js and browser setups.Notes
Thanks for reviewing this contribution!