Skip to content

chore: Add typescript check for form component library#18899

Open
phlipsterit wants to merge 11 commits into
mainfrom
chore/ts-check-form-component
Open

chore: Add typescript check for form component library#18899
phlipsterit wants to merge 11 commits into
mainfrom
chore/ts-check-form-component

Conversation

@phlipsterit
Copy link
Copy Markdown
Contributor

@phlipsterit phlipsterit commented May 20, 2026

Fixes such that "yarn typecheck" runs without error in libs/form-component and also runs this in form-component CI action

Description

  • Remove import of React, since we are using jsx transform "react-jsx" which dont need this import.
  • Use colorType from designsystem in Card to avoid ts-error
  • Map button color 'success' to custom styling, since button in designsystem does not support this color out of the box
  • Set required prop onValueChange in story for DatePicker.

Verification

  • Related issues are connected (if applicable)
  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • Bug Fixes

    • Spinner now exposes a loading signal for improved downstream rendering (e.g. PDF export).
  • Refactoring

    • Button colour handling enhanced with a new "success" appearance and improved class composition.
    • Several components modernised (cleaner imports) and prop typings aligned, including Card colour typing.
  • Documentation

    • Datepicker preview story updated to wire interactive handlers for more accurate previews.
  • Chores

    • CI now installs dependencies and runs type checks.

Review Change Stack

@phlipsterit phlipsterit self-assigned this May 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a51c19f-b2d0-495f-8c87-b35cc38fc7b8

📥 Commits

Reviewing files that changed from the base of the PR and between 32d0f87 and 03ae402.

📒 Files selected for processing (1)
  • libs/form-component/src/app-components/Button/Button.tsx

📝 Walkthrough

Walkthrough

Form component modules remove default React imports or switch to named imports; Button mapping now returns {data-color, className} with a local success class; Card typing aligns to design-system data-color; Spinner wraps the design-system spinner with data-loading; Datepicker story wiring adds a mock handler; CI enables type-checking.

Changes

Form component library updates

Layer / File(s) Summary
React import standardisation
libs/form-component/src/app-components/Datepicker/DatepickerDialog.tsx, libs/form-component/src/app-components/Input/FormattedInput.tsx, libs/form-component/src/app-components/Input/NumericInput.tsx
Unused/default React imports removed or replaced with named/type imports across several components.
Button colour mapping and CSS
libs/form-component/src/app-components/Button/Button.tsx, libs/form-component/src/app-components/Button/Button.module.css
mapColorNames now returns an object with optional data-color and/or className; 'success' maps to a local .buttonSuccess CSS class; render uses data-color={mappedColor} and applies combined className.
Card prop typing alignment
libs/form-component/src/app-components/Card/Card.tsx
AppCardProps.color now uses CardProps['data-color'] from the design-system types.
Spinner design-system wrapper
libs/form-component/src/app-components/Spinner/Spinner.tsx
Spinner re-implemented as a typed wrapper around the design-system Spinner, adding data-loading and forwarding props.
Datepicker Storybook & dialog
libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx, libs/form-component/src/app-components/Datepicker/DatepickerDialog.tsx
Storybook fn mock imported and Preview.args.onValueChange set to fn(); Wrapper calls args.onValueChange then updates local state; dialog uses named React hooks only.
CI: enable type checking
.github/workflows/libs-form-component-unit-tests.yml
Adds active yarn --immutable install step and enables yarn typecheck in the workflow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

kind/chore

Suggested reviewers

  • framitdavid
  • adamhaeger

Poem

🐰 I hopped through imports, neat and spry,

Swapped defaults for types beneath the sky.
Buttons donned a green success coat,
Spinner hums "loading" — give it a note,
Stories mock-ready — hop, test, and try!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: Add typescript check for form component library' accurately reflects the main objective of the PR - adding TypeScript checking to the CI workflow for the form-component library.
Description check ✅ Passed The description adequately covers the key changes and rationale (React imports, Card colourType, Button success styling, DatePicker story prop). However, all verification checklist items remain unchecked, indicating the author has not completed the self-verification requirements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ts-check-form-component

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@phlipsterit phlipsterit added the squad/utforming Issues that belongs to the named squad. label May 20, 2026
@phlipsterit phlipsterit changed the title chore : add ts check for form component library chore: Add typescript check for form component library May 20, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx (1)

26-29: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

The mock function is overridden and never called.

The onValueChange: fn() mock added to the story args (line 39) is immediately overridden by the explicit onValueChange={setValue} prop in the Wrapper component (line 28). This means the mock function will never be invoked, defeating the purpose of adding it for interaction tracking in Storybook.

Consider one of these solutions:

Option 1: Remove the override and rely on args:

📝 Remove explicit onValueChange override
 const Wrapper = (args: React.ComponentProps<typeof DatePickerControl>) => {
   const [value, setValue] = useState(args.value);
-  return <DatePickerControl {...args} value={value} onValueChange={setValue} />;
+  return <DatePickerControl {...args} value={value} onValueChange={(val) => {
+    setValue(val);
+    args.onValueChange?.(val);
+  }} />;
 };

Option 2: Call both handlers:
This ensures local state updates whilst also invoking the mock for Storybook's Actions addon.

Also applies to: 39-39

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx`
around lines 26 - 29, The Wrapper currently overrides the storybook mock
onValueChange (fn()) by passing onValueChange={setValue} so the mock is never
called; fix by either removing the explicit override (let DatePickerControl
receive value and onValueChange from args and use args.value as initial state)
or change the handler in Wrapper to a composed function that calls
setValue(newVal) and then calls args.onValueChange?.(newVal) (reference Wrapper,
DatePickerControl, setValue, args.onValueChange, fn()) so the mock/action is
invoked while still updating local state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx`:
- Around line 26-29: The Wrapper currently overrides the storybook mock
onValueChange (fn()) by passing onValueChange={setValue} so the mock is never
called; fix by either removing the explicit override (let DatePickerControl
receive value and onValueChange from args and use args.value as initial state)
or change the handler in Wrapper to a composed function that calls
setValue(newVal) and then calls args.onValueChange?.(newVal) (reference Wrapper,
DatePickerControl, setValue, args.onValueChange, fn()) so the mock/action is
invoked while still updating local state.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db35f921-a111-477d-adbc-c1d0d9a59e1d

📥 Commits

Reviewing files that changed from the base of the PR and between ff4a47f and c920838.

📒 Files selected for processing (7)
  • libs/form-component/src/app-components/Button/Button.tsx
  • libs/form-component/src/app-components/Datepicker/DatePickerCalendar.tsx
  • libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx
  • libs/form-component/src/app-components/Datepicker/DatepickerDialog.tsx
  • libs/form-component/src/app-components/Input/FormattedInput.tsx
  • libs/form-component/src/app-components/Input/NumericInput.tsx
  • libs/form-component/src/app-components/Spinner/Spinner.tsx
💤 Files with no reviewable changes (4)
  • libs/form-component/src/app-components/Input/NumericInput.tsx
  • libs/form-component/src/app-components/Datepicker/DatePickerCalendar.tsx
  • libs/form-component/src/app-components/Input/FormattedInput.tsx
  • libs/form-component/src/app-components/Spinner/Spinner.tsx

@phlipsterit phlipsterit marked this pull request as draft May 21, 2026 06:17
@github-actions github-actions Bot added the skip-releasenotes Issues that do not make sense to list in our release notes label May 21, 2026
@phlipsterit phlipsterit marked this pull request as ready for review May 21, 2026 09:29
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/form-component/src/app-components/Button/Button.tsx`:
- Line 63: The explicit type assertion on data-color is bypassing TypeScript
safety: locate the usage of mapColorNames in Button.tsx and remove the cast to
DesignSystemButtonProps['data-color']; then either (A) if 'success' is an
allowed design-system token, add 'success' to the DesignSystemButtonProps
type/union so mapColorNames returns a valid value, or (B) if 'success' is not
supported, stop asserting the return type and handle 'success' separately (e.g.
filter/translate it to a supported token or apply the manual CSS override
mentioned in the comment) so only valid values are passed to the design-system
data-color prop.

In `@libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx`:
- Line 28: Rename the misspelled function handleVAlueChange to handleValueChange
everywhere it's defined and referenced in the Datepicker stories; update the
function declaration and any event handlers or props that call handleVAlueChange
to use handleValueChange so identifiers stay consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1aab7886-009f-4316-9960-396e46b19146

📥 Commits

Reviewing files that changed from the base of the PR and between c920838 and f4f6d17.

📒 Files selected for processing (4)
  • .github/workflows/libs-form-component-unit-tests.yml
  • libs/form-component/src/app-components/Button/Button.tsx
  • libs/form-component/src/app-components/Card/Card.tsx
  • libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx
✅ Files skipped from review due to trivial changes (1)
  • libs/form-component/src/app-components/Card/Card.tsx

Comment thread libs/form-component/src/app-components/Button/Button.tsx Outdated
Comment thread libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx Outdated
Copy link
Copy Markdown
Contributor

@framitdavid framitdavid left a comment

Choose a reason for hiding this comment

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

Nå snakket vi om denne på forhånd, men tok review likevel og synes dette ble pent. 🥇Godt jobbet. 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-releasenotes Issues that do not make sense to list in our release notes squad/utforming Issues that belongs to the named squad.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants