Skip to content

Conversation

@mfranzke
Copy link
Collaborator

@mfranzke mfranzke commented Nov 17, 2025

Proposed changes

In general we're using any way too often, whereas it should only be used in rare cases if at all (in some it might still be unknown).

Types of changes

  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improvements to existing components or architectural decisions)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Further comments

🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/refactor-typescript-migrate-any

@mfranzke mfranzke self-assigned this Nov 17, 2025
@mfranzke mfranzke added the 🍄🆙improvement New feature or request label Nov 17, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 17, 2025

⚠️ No Changeset found

Latest commit: 608c713

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

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 aims to reduce the use of any types in TypeScript by replacing them with more specific types. The change updates the handleKeyboardPress function signature in the custom-select component to use GeneralKeyboardEvent<HTMLInputElement> instead of any.

Key Changes

  • Imported GeneralKeyboardEvent type from shared model
  • Updated handleKeyboardPress type signature from any to GeneralKeyboardEvent<HTMLInputElement> in both model definition and implementation

Reviewed Changes

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

File Description
packages/components/src/components/custom-select/model.ts Added GeneralKeyboardEvent import and updated handleKeyboardPress type in DBCustomSelectDefaultState
packages/components/src/components/custom-select/custom-select.lite.tsx Added GeneralKeyboardEvent import and updated handleKeyboardPress parameter type in implementation
Comments suppressed due to low confidence (2)

packages/components/src/components/custom-select/model.ts:288

  • The handleDropdownToggle parameter type should be updated from any to match its implementation, which uses GeneralEvent<HTMLDetailsElement>. The implementation at line 176 of custom-select.lite.tsx already has the correct type.
	handleDropdownToggle: (event: any) => void;

packages/components/src/components/custom-select/model.ts:287

  • The handleSelectAll and handleClearAll parameter types should be updated from any to ClickEvent<HTMLButtonElement> or a more specific event type. Both implementations call event.stopPropagation(), indicating they receive standard DOM events. Review the actual event sources to determine the most appropriate type.
	handleSelectAll: (event: any) => void;
	handleClearAll: (event: any) => void;

@mfranzke mfranzke requested a review from Copilot November 17, 2025 19:26
Copilot finished reviewing on behalf of mfranzke November 17, 2025 19:29
Copy link
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (4)

packages/components/src/components/custom-select/custom-select.lite.tsx:288

  • The handleArrowDownUp method still uses any for the event parameter. According to the model.ts changes (line 295), this should be typed as GeneralKeyboardEvent<HTMLElement> to match the interface definition and align with the PR's goal of removing any types.
		handleArrowDownUp: (event: any) => {

packages/components/src/components/custom-select/custom-select.lite.tsx:463

  • The handleDocumentClose implementation still uses any for the event parameter. According to the model.ts changes (line 289), this should be typed as GeneralEvent<HTMLElement> to match the interface definition.
		handleDocumentClose: (event: any) => {

packages/components/src/components/custom-select/custom-select.lite.tsx:529

  • The handleSelectAll method still uses any for the event parameter. Based on usage at line 1062 where it's called from an onChange handler on a checkbox input, this should be typed as ChangeEvent<HTMLInputElement> to provide proper type safety.
		handleSelectAll: (event: any) => {

packages/components/src/components/custom-select/custom-select.lite.tsx:636

  • The handleClearAll method still uses any for the event parameter. Based on usage at line 1179 where it's called from an onClick handler on a DBButton, this should be typed as ClickEvent<HTMLButtonElement> to provide proper type safety.
		handleClearAll: (event: any) => {

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

Labels

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

2 participants