Skip to content

Conversation

@hparra
Copy link
Member

@hparra hparra commented May 21, 2025

Adds TypeScript definition files (.d.ts) to your project, enabling improved integration and developer experience for TypeScript users.

Description

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.

Related Issue

Fixes #10

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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
Copy link

codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (86bf790) to head (7d8d7fc).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hparra hparra marked this pull request as ready for review May 21, 2025 03:39
@purplecabbage purplecabbage requested a review from Copilot May 27, 2025 16:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@purplecabbage purplecabbage merged commit 86698a9 into adobe:master May 27, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add explicit typings file to this lib

2 participants