Skip to content

#8628 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 20 - #8634

Merged
AlexeyGirin merged 2 commits into
masterfrom
copilot/refactor-props-validation-to-typescript-yet-again
Nov 21, 2025
Merged

AlexeyGirin merged 2 commits into
masterfrom
copilot/refactor-props-validation-to-typescript-yet-again

Conversation

Copilot AI commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor

React components should validate prop types for type safety and maintainability. The errorPopover component was using untyped JavaScript props.

Changes

  • Added ErrorPopoverProps interface defining all prop types:

    • error: string - error message content
    • anchorEl: HTMLElement | null - popover anchor element
    • open?: boolean - visibility control (defaults to true)
    • onClose?: () => void - close handler callback
  • Fixed prop naming: handleClose → onClose to match actual usage in form.jsx

interface ErrorPopoverProps {
  error: string;
  anchorEl: HTMLElement | null;
  open?: boolean;
  onClose?: () => void;
}

export const ErrorPopover = ({
  error,
  anchorEl,
  open = true,
  onClose,
}: ErrorPopoverProps) => (
  // ...
);
Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor: Variables are missing in props validation (let's rewrite JS to TS) 20</issue_title>
<issue_description>Problem: Variables are missing in props validation
React components should validate prop types

Why is this an issue?
In JavaScript, props are typically passed as plain objects, which can lead to errors and confusion when working with components that have specific prop requirements. However, it lacks of type safety and clarity when passing props to components in a codebase.

By defining types for component props, developers can enforce type safety and provide clear documentation for the expected props of a component. This helps catch potential errors at compile-time. It also improves code maintainability by making it easier to understand how components should be used and what props they accept.

How can I fix it?
Let re-write the entire file on TypeScript and define types for all props.

Problem locations:
packages/ketcher-react/src/script/ui/component/form/form/errorPopover.jsx</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor variables to enforce props validation with TypeScript Convert errorPopover.jsx to TypeScript with proper prop types Nov 21, 2025
Copilot AI requested a review from AlexeyGirin November 21, 2025 06:27
@AlexeyGirin
AlexeyGirin marked this pull request as ready for review November 21, 2025 08:26
@AlexeyGirin
AlexeyGirin requested review from rrodionov91 and removed request for AlexeyGirin, NataliaLoginova and Zhirnoff November 21, 2025 08:27
@AlexeyGirin AlexeyGirin changed the title Convert errorPopover.jsx to TypeScript with proper prop types #8628 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 20 Nov 21, 2025
@AlexeyGirin
AlexeyGirin merged commit e637436 into master Nov 21, 2025
14 of 15 checks passed
@AlexeyGirin
AlexeyGirin deleted the copilot/refactor-props-validation-to-typescript-yet-again branch November 21, 2025 11:07
AlexeyGirin added a commit that referenced this pull request Nov 21, 2025
…ite JS to TS) 16 (#8630)

* Initial plan

* Refactor cliparea.jsx to TypeScript with proper prop type validation

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* fix: Context menu remains visible after creating cyclic structure via right-click menu (#8601)

* #7326 - Preview: Delete option is unavailable when right-clicking on a bond in macro mode (#8636)

* fix: Delete option is available when right-clicking on a bond in macro mode

* test: update snapshots

* fix: Selection tool icon open dropdown menu as in Micro mode (#8621)

* #8612 Refactor: Prefer tag over ARIA role (part 4) (#8615)

* Initial plan

* Replace div role="button" with semantic button elements

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Remove redundant aria-disabled attribute in favor of native disabled

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* f1

* f2

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Co-authored-by: Alexey Girin <agirin@mail.ru>

* #8504 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 7 (#8616)

* Initial plan

* Convert TypeChoice.jsx to TypeScript with proper type definitions

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Add explanatory comments for type compatibility and required props

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8619 Refactor: Expected a for-of loop instead of a for loop with this simple iteration (part 4) (#8620)

* Initial plan

* Refactor for loops to for-of loops in utils.js

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8563 Refactor: Mark the props of the component as read-only (#8622)

* Initial plan

* Mark component props as read-only using Readonly utility type

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8626 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 18 (#8632)

* Initial plan

* Refactor buttonlist.jsx to TypeScript with proper type definitions

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Fix parameter naming: rename 'multipl' to 'multiple' in oneOrMore function

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8627 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 19 (#8633)

* Initial plan

* Convert ComboBox component from JSX to TypeScript with proper prop types

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Address code review feedback - improve type safety and JSX rendering

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8628 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 20 (#8634)

* Initial plan

* Convert errorPopover.jsx to TypeScript with proper type definitions

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Initial plan

* f1

* f2

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Co-authored-by: Kristina <kristina_kasyanovskaya@epam.com>
Co-authored-by: Alexey Girin <agirin@mail.ru>
KukushkinDmi1riy pushed a commit that referenced this pull request Dec 3, 2025
…ite JS to TS) 20 (#8634)

* Initial plan

* Convert errorPopover.jsx to TypeScript with proper type definitions

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
KukushkinDmi1riy pushed a commit that referenced this pull request Dec 3, 2025
…ite JS to TS) 16 (#8630)

* Initial plan

* Refactor cliparea.jsx to TypeScript with proper prop type validation

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* fix: Context menu remains visible after creating cyclic structure via right-click menu (#8601)

* #7326 - Preview: Delete option is unavailable when right-clicking on a bond in macro mode (#8636)

* fix: Delete option is available when right-clicking on a bond in macro mode

* test: update snapshots

* fix: Selection tool icon open dropdown menu as in Micro mode (#8621)

* #8612 Refactor: Prefer tag over ARIA role (part 4) (#8615)

* Initial plan

* Replace div role="button" with semantic button elements

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Remove redundant aria-disabled attribute in favor of native disabled

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* f1

* f2

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Co-authored-by: Alexey Girin <agirin@mail.ru>

* #8504 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 7 (#8616)

* Initial plan

* Convert TypeChoice.jsx to TypeScript with proper type definitions

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Add explanatory comments for type compatibility and required props

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8619 Refactor: Expected a for-of loop instead of a for loop with this simple iteration (part 4) (#8620)

* Initial plan

* Refactor for loops to for-of loops in utils.js

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8563 Refactor: Mark the props of the component as read-only (#8622)

* Initial plan

* Mark component props as read-only using Readonly utility type

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8626 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 18 (#8632)

* Initial plan

* Refactor buttonlist.jsx to TypeScript with proper type definitions

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Fix parameter naming: rename 'multipl' to 'multiple' in oneOrMore function

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8627 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 19 (#8633)

* Initial plan

* Convert ComboBox component from JSX to TypeScript with proper prop types

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Address code review feedback - improve type safety and JSX rendering

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* #8628 Refactor: Variables are missing in props validation (let's rewrite JS to TS) 20 (#8634)

* Initial plan

* Convert errorPopover.jsx to TypeScript with proper type definitions

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Initial plan

* f1

* f2

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Co-authored-by: Kristina <kristina_kasyanovskaya@epam.com>
Co-authored-by: Alexey Girin <agirin@mail.ru>
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.

Refactor: Variables are missing in props validation (let's rewrite JS to TS) 20

3 participants