Web components: TypeScript conversion and build improvements#223
Merged
ethangardner merged 10 commits intodevelopfrom Nov 18, 2025
Merged
Web components: TypeScript conversion and build improvements#223ethangardner merged 10 commits intodevelopfrom
ethangardner merged 10 commits intodevelopfrom
Conversation
🦋 Changeset detectedLatest commit: 8259a19 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Resolved vite error and provided types export in package. Signed-off-by: Ethan Gardner <ethangardner@users.noreply.github.com>
iamjolly
approved these changes
Nov 18, 2025
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.
Summary
Converted core component files to TypeScript, implemented automatic type definition generation, and refined the build configuration for better Lit dependency handling. Also, a minor style improvement was made to the banner component's language text alignment.
Closes #221
Closes #222
Preview link: N/A
Problem Statement
The project aimed to enhance code quality and maintainability through TypeScript adoption, provide accurate type definitions for library consumers, and establish a robust build process compatible with modern JavaScript modules and Lit dependencies. However, several core component files were still in JavaScript, leading to a lack of type safety. Additionally, type definitions were not automatically generated, and the existing Vite build configuration encountered issues with Lit dependencies in certain environments. The banner component also exhibited an inconsistent default text alignment for its language display.
These issues impacted internal development efficiency, external consumer experience due to missing type information, and introduced potential build instability, alongside a minor visual inconsistency.
Solution Summary
This pull request addresses the identified problems by:
src/components/index.js,src/components/usa-link/index.js, andsrc/components/usa-link/usa-link.spec.jsto their respective.tscounterparts. This enhances type safety and developer experience.vite-plugin-dtsintoconfig/vite.config.ts. This plugin automates the creation of.d.tsfiles during the build process, ensuring that consumers of the library have access to accurate type information.rollupOptions.externalproperty inconfig/vite.config.tsto use a more robust regular expression (/^@?lit(-\w+)?($|\/.+)/). This change specifically resolves known issues related to Lit dependencies within Vite environments, ensuring they are correctly handled as external modules.text-align: start;to the.usa-banner__languageselector insrc/components/usa-banner/usa-banner.css. This provides a consistent and accessible default text alignment for the banner's language display.These changes collectively improve the project's maintainability, developer experience, build reliability, and consistency.
Recommended methods for reviewing this change
npm run buildto ensure the project builds successfully and verify that.d.tsfiles are generated in thedistdirectory.usa-linkcomponent to confirm it functions as expected after the TypeScript conversion.usa-bannercomponent in a browser (e.g., via Storybook) to visually confirm that the language text is aligned to thestart.config/vite.config.tsto review the integration ofvite-plugin-dtsand the updatedrollupOptionsfor external dependencies and output format.tsc --noEmitto ensure there are no new TypeScript errors introduced by the changes.