Skip to content

#11901 - rewrite packages\ketcher-core\src\application\editor\shared\closest.js from javascript to typescript - #11912

Open
armankarapetyan-svg wants to merge 2 commits into
masterfrom
11901-lets-rewrite-packagesketcher-coresrcapplicationeditorsharedclosestjs-from-javascript-to-typescript
Open

armankarapetyan-svg wants to merge 2 commits into
masterfrom
11901-lets-rewrite-packagesketcher-coresrcapplicationeditorsharedclosestjs-from-javascript-to-typescript

Conversation

@armankarapetyan-svg

@armankarapetyan-svg armankarapetyan-svg commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

Converted closest.js to TypeScript with proper type definitions. Here's what was done:

  1. Created Type Definitions File (closest.types.ts)
    Created closest.types.ts with the following exported types:
  • ClosestAtom - Result interface with id: number and dist: number
  • ClosestSkipItem - Skip item interface with map: 'atoms' and id: number
  • FindClosestAtom - Function type for the main search function
  • ClosestModule - Export interface for the module
  1. Converted to TypeScript (closest.ts)
    Created closest.ts with:

Type Conversions:

  • restruct: ReStruct - The render structure type
  • pos: Vec2 - Vector position type
  • skip: ClosestSkipItem | null - Skip item or null (no implicit any)
  • minDist: number | null - Minimum distance or null
  • closestAtom: number | null - Atom ID or null
  • Return type: ClosestAtom | null - Explicit return type

Key Improvements:

  • All function parameters are explicitly typed
  • All variables have resolved types (no any types)
  • Added JSDoc comments for better documentation
  • Proper type safety with strict TypeScript compiler

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

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.

Let's rewrite packages\ketcher-core\src\application\editor\shared\closest.js from JavaScript to TypeScript

1 participant