Skip to content

feat(types): add explicit TypeScript types across the codebase#243

Open
tomadowley wants to merge 3 commits intomasterfrom
cosine/add-types-everywhere
Open

feat(types): add explicit TypeScript types across the codebase#243
tomadowley wants to merge 3 commits intomasterfrom
cosine/add-types-everywhere

Conversation

@tomadowley
Copy link
Owner

This change introduces comprehensive typing throughout the project to improve type safety and maintainability. Key updates include:

  • Python engine.py: added explicit types for constants and function signature (GREETING: str, SIGNOFF: str, greet(name: str) -> str).
  • React app: App component is now typed as React.FC; minor structural typing improvements to App.tsx.
  • Sorting utilities (TypeScript): added concrete types across all sorting algorithms:
    • bubbleSort, insertionSort, selectionSort, mergeSort, quickSort, heapSort, randomSort now use explicit types for numbers, generics (T), and arrays (T[], number[], etc).
    • Added precise type annotations for loop indices, keys, and helper variables (e.g., n: number, minIdx: number, key: T, left: T[], right: T[]).
  • Prime checker (PrimeChecker.tsx): introduced a ResultState type alias (boolean | null) and wired state hooks with explicit types (input: string, checked: boolean, isPrimeResult: ResultState). Ensures consistent state handling for tri-state result.
  • index.tsx: added robust container typing and a runtime check for the root container before creating the React root, improving runtime safety.
  • Additional modules (insertionSort.ts, mergeSort.ts, primeGenerator.ts, randomSort.ts, reportWebVitals.ts, selectionSort.ts): added precise type annotations to parameters, return types, and internal variables (e.g., mid: number, left: number[], right: number[], isPrime checks, etc.).

These changes collectively enforce stronger type safety and help catch type-related issues earlier during development.


This pull request was co-created with Cosine Genie

Original Task: sorbox/hic0pyrmko3s
Author: Tom Dowley

…er in index.tsx; fix various TSX typings.

Co-authored-by: Cosine <agent@cosine.sh>
@vercel
Copy link

vercel bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sorbox Ready Ready Preview, Comment Jan 27, 2026 1:19pm

…eact.ReactNode for resultElem

Co-authored-by: Cosine <agent@cosine.sh>
…selectionSort

Co-authored-by: Cosine <agent@cosine.sh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant