Skip to content

Conversation

shleewhite
Copy link
Contributor

@shleewhite shleewhite commented Jul 11, 2025

📌 Summary

If merged, this PR would fix some type issues found while converting the forms routes to TypeScript.

  • Form::Fieldset: export an array of the layout options
  • Form::Header::Title: fix the type of the exported array of available tags
  • Form::TextInput: fix the type of the exported array of available input types
  • Text::Display: fix the type of the exported array of available text sizes

It also fixes a type issue with the @resultCountMessage argument for the Form::SuperSelect::Single and Form::SuperSelect::Multiple.

Before the fix, the type for @resultCountMessage was ((resultCount: number) => string) & string because the type was inherited from PowerSelectSignature['Args'] and also set in the interface, see:
Screenshot 2025-07-15 at 10 25 37 AM

This made it so the type was never correct if you set it to a string or a function.

The fix was to omit the arg from being inherited and only setting the type in the interface, see:
Screenshot 2025-07-15 at 10 35 00 AM

This type error happened because our custom after options component expects a string (link), while the actual power select component expects a function.

To resolve this, I just made different getters for each that return either a string or a function and then can be passed to the right place.
Screenshot 2025-07-15 at 10 29 23 AM

🔗 External links

Jira ticket: HDS-5101


👀 Component checklist

💬 Please consider using conventional comments when reviewing this PR.

📋 PCI review checklist
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've worked with GRC to document the impact of any changes to security controls.
    Examples of changes to controls include access controls, encryption, logging, etc.
  • If applicable, I've worked with GRC to ensure compliance due to a significant change to the in-scope PCI environment.
    Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.

Copy link

vercel bot commented Jul 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
hds-showcase ✅ Ready (Inspect) Visit Preview Jul 16, 2025 0:22am
hds-website ✅ Ready (Inspect) Visit Preview Jul 16, 2025 0:22am

Base automatically changed from showcase/ts-batch-1 to main July 14, 2025 16:09
@shleewhite shleewhite force-pushed the hds-5101/ts-const-fix branch from 1ca37e0 to 4599060 Compare July 14, 2025 16:28
@shleewhite shleewhite force-pushed the hds-5101/ts-const-fix branch from 4599060 to 17092d0 Compare July 15, 2025 14:19
@shleewhite shleewhite changed the title Form::Fieldset: add constant export for layout options Form::Fieldset, Form::Header, Text::Display, Form:SuperSelect, Form::TextInput: small type fixes Jul 15, 2025
@shleewhite shleewhite marked this pull request as ready for review July 15, 2025 14:45
@shleewhite shleewhite requested a review from a team as a code owner July 15, 2025 14:45
@shleewhite shleewhite requested a review from Copilot July 15, 2025 14:46
Copy link
Contributor

@Copilot 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 fixes TypeScript typing issues across several form and text components and refines the @resultCountMessage argument in the single/multiple super-select components to cleanly accept either a string or a function.

  • Export and cast enums’ values arrays to their proper literal types (HdsTextSizes[], HdsFormTextInputTypes[], HdsFormHeaderTitleTags[], HdsFormFieldsetLayouts[]).
  • Omit the inherited resultCountMessage from PowerSelectSignature and redefine it as a union of string or function in both single and multiple super-select bases.
  • Update Handlebars templates to wire up only the function variant to PowerSelect and add the corresponding changeset.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/components/src/components/hds/text/display.ts Cast AVAILABLE_SIZES to HdsTextSizes[]
packages/components/src/components/hds/form/text-input/base.ts Typed TYPES as HdsFormTextInputTypes[]
packages/components/src/components/hds/form/super-select/single/base.ts Omit and redefine resultCountMessage in the single base signature and add getters
packages/components/src/components/hds/form/super-select/single/base.hbs Wire up function variant of resultCountMessage to PowerSelect
packages/components/src/components/hds/form/super-select/multiple/base.ts Same signature and getters adjustments for multiple base
packages/components/src/components/hds/form/super-select/multiple/base.hbs Wire up function variant of resultCountMessage to PowerSelect
packages/components/src/components/hds/form/header/title.ts Typed AVAILABLE_TAGS as HdsFormHeaderTitleTags[]
packages/components/src/components/hds/form/fieldset/index.ts Export typed LAYOUT_TYPES for fieldset layouts
.changeset/fresh-horses-wink.md Added changeset entry for the super-select fix
Comments suppressed due to low confidence (3)

packages/components/src/components/hds/form/fieldset/index.ts:24

  • [nitpick] To align with existing constants like AVAILABLE_SIZES and AVAILABLE_TAGS, consider renaming LAYOUT_TYPES to AVAILABLE_LAYOUTS or AVAILABLE_LAYOUT_TYPES for consistency.
export const LAYOUT_TYPES: HdsFormFieldsetLayouts[] = Object.values(

packages/components/src/components/hds/form/super-select/single/base.ts:57

  • Consider adding unit tests to cover both the string and function cases for resultCountMessageFunction in the single super-select component to ensure this branching logic is verified.
  get resultCountMessageFunction() {

packages/components/src/components/hds/form/super-select/multiple/base.ts:68

  • Add tests for the resultCountMessageFunction getter in the multiple super-select to validate that it correctly returns a function or undefined as intended.
  get resultCountMessageFunction() {

Copy link
Contributor

@dchyun dchyun left a comment

Choose a reason for hiding this comment

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

A few minor / non-blocking comments but lgtm!

dchyun
dchyun previously approved these changes Jul 15, 2025
dchyun
dchyun previously approved these changes Jul 15, 2025
Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

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

left a couple of comments

@shleewhite shleewhite merged commit a5a5192 into main Jul 16, 2025
16 checks passed
@shleewhite shleewhite deleted the hds-5101/ts-const-fix branch July 16, 2025 14:25
@hashibot-hds hashibot-hds mentioned this pull request Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants