Skip to content

TypeScript Type Error When Using rc-select with CSS Modules and Vite. #1143

Closed as not planned

Description

@junhaoliao

When using rc-select with CSS Modules and Vite, the following error occurs with exactOptionalPropertyTypes: true enabled:

CSS Module:

/* myStyles.module.css */
.selectBox {
  /* styles */
}

Component:

import styles from "myStyles.module.css"

const MyComponent = () => (
  <Select className={styles["selectBox"]} />
);

Error:

TS2375: Type { className: string | undefined; } is not assignable to type SelectProps<any, DefaultOptionType> with 'exactOptionalPropertyTypes: true'. Consider adding undefined to the types of the target's properties.
Types of property className are incompatible.
Type string | undefined is not assignable to type string
Type undefined is not assignable to type string

Activity

  1. added a commit that references this issue on Apr 10, 2025
    55e35d6
  2. hiSandog commented on Jul 5, 2026

    @hiSandog

    This looks like a good regression-test candidate because the failure is narrowed to “TypeScript Type Error When Using rc-select with CSS Modules and Vite.”. If a minimal fixture can exercise rc-select and assert the expected behavior around exactOptionalPropertyTypes: true, it would make the eventual fix much easier to keep from regressing.

  3. afc163 commented on Jul 5, 2026

    @afc163
    Member

    Thanks for the report. We are going to keep the current prop typings as-is and do not plan to adjust rc-select specifically for exactOptionalPropertyTypes compatibility here.

    For CSS Modules that may return string | undefined, please normalize the value before passing it to className, or avoid passing the prop when the class is missing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions