feat: Add TypeScript definitions#166
Merged
purplecabbage merged 2 commits intoadobe:masterfrom May 27, 2025
Merged
Conversation
Adds TypeScript definition files (`.d.ts`) to your project, enabling improved integration and developer experience for TypeScript users. Key changes: - Generated type definitions for all modules in `src/` and placed them in the `types/` directory. - Created `tsconfig.json` to configure TypeScript compilation for declaration generation. - Refined the main `types/index.d.ts` to ensure accurate types for exported members, replacing `any` types with more specific ones (e.g., for `context`, `getToken`). - Added a type test file (`test/types.test.ts`) that imports and uses various parts of the library to ensure the types compile correctly. - Verified that `package.json` includes the `types` field pointing to `types/index.d.ts` and a `build:types` script. These changes allow TypeScript projects to seamlessly use this package with full type checking and autocompletion support.
Renames `test/types.test.ts` to `test/types.check.ts` to prevent Jest from attempting to execute it as a test case. The primary purpose of this file is static type checking using `tsc`, not runtime testing with Jest. - Renamed `test/types.test.ts` to `test/types.check.ts`. - Ensured `test/types.check.ts` is included in `tsconfig.json` for continued static type analysis by `tsc`. - Verified that `npm test` now passes as Jest no longer tries to parse this TypeScript file. - Confirmed that `npx tsc --noEmit test/types.check.ts` also passes, ensuring the file's type integrity. This change resolves test failures in CI/CD environments where Jest attempts to run all `*.test.ts` files without appropriate TypeScript transpilation configured for this specific static check file.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #166 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 490 490
Branches 69 69
=========================================
Hits 490 490 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds TypeScript definition files to the project, enhancing TypeScript integration with complete type checking and improved developer experience.
- Generated declaration files for modules in src/ and placed them in the types/ directory.
- Updated package.json to include a types field and a build:types script.
- Added a type test file to verify the accuracy and integration of the new type definitions.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/types.check.ts | Added a type test file importing and exercising the new TypeScript types. |
| package.json | Updated TypeScript version and added types/build:types configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds TypeScript definition files (
.d.ts) to your project, enabling improved integration and developer experience for TypeScript users.Description
Key changes:
src/and placed them in thetypes/directory.tsconfig.jsonto configure TypeScript compilation for declaration generation.types/index.d.tsto ensure accurate types for exported members, replacinganytypes with more specific ones (e.g., forcontext,getToken).test/types.test.ts) that imports and uses various parts of the library to ensure the types compile correctly.package.jsonincludes thetypesfield pointing totypes/index.d.tsand abuild:typesscript.These changes allow TypeScript projects to seamlessly use this package with full type checking and autocompletion support.
Related Issue
Fixes #10
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: