Skip to content

Refactor TS types - #413

Open
thinklanguages wants to merge 1 commit into
mainfrom
codex/fix-typescript-type-errors-and-unused-variables
Open

Refactor TS types#413
thinklanguages wants to merge 1 commit into
mainfrom
codex/fix-typescript-type-errors-and-unused-variables

Conversation

@thinklanguages

@thinklanguages thinklanguages commented Jun 26, 2025

Copy link
Copy Markdown
Owner

Summary

  • remove explicit any usage in front-end logging functions
  • tighten global gtag type declaration
  • refine polling callbacks and update fetch helper types
  • add response interfaces for API calls
  • adjust admin handlers and utilities to use new interfaces
  • handle potentially missing data in generation helpers

Testing

  • npm run lint (fails: Cannot find package '@typescript-eslint/eslint-plugin')
  • composer lint (fails: command not found)
  • composer test (fails: command not found)
  • npm run build (fails: vite not found)

https://chatgpt.com/codex/tasks/task_e_685d18e866a08327852dcc1f6f106a03

Description by Korbit AI

What change is being made?

Refactor TypeScript types by replacing any with more explicit type definitions across various modules, including defining interfaces for API responses and updating function typings to enhance type safety.

Why are these changes being made?

These changes are made to improve code maintainability and robustness by enforcing stricter type checking, which helps prevent runtime errors and supports better code documentation. This approach ensures more predictable behavior in TypeScript by reducing loosely typed instances and standardizing the handling of API responses.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

@korbit-ai korbit-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Functionality Unbounded Polling Interval ▹ view
Design Incomplete Type Safety in PollUpdate Interface ▹ view
Files scanned
File Path Reviewed
src/front/ts/logger.ts
src/admin/ts/utils/logger.ts
src/front/ts/nuclen-front-global.ts
src/admin/ts/utils/api.ts
src/admin/ts/generation/polling.ts
src/admin/ts/generation/results.ts
src/admin/ts/generate/generate-page-utils.ts
src/admin/ts/single/single-generation-utils.ts
src/admin/ts/nuclen-admin-onboarding.ts
src/admin/ts/single/single-generation-handlers.ts
src/front/ts/nuclen-quiz-results.ts
src/admin/ts/generate/step2.ts
src/admin/ts/generate/step1.ts
src/admin/ts/generation/api.ts
src/front/ts/nuclen-quiz-main.ts

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

import { nuclenFetchUpdates, PollUpdate } from './api';

export function NuclenPollAndPullUpdates({
intervalMs = 5000,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unbounded Polling Interval category Functionality

Tell me more
What is the issue?

The polling interval is hardcoded to 5 seconds without any validation for minimum or maximum values, which could lead to API abuse or inefficient polling.

Why this matters

Without bounds checking, users could set extremely short intervals that could overwhelm the server or very long intervals that make the polling ineffective.

Suggested change ∙ Feature Preview

Add validation for the polling interval:

intervalMs = Math.max(Math.min(intervalMs ?? 5000, 30000), 1000), // Min 1s, Max 30s, Default 5s
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

successCount?: number;
failCount?: number;
finalReport?: { message?: string };
results?: Record<string, any>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete Type Safety in PollUpdate Interface category Design

Tell me more
What is the issue?

The PollUpdate interface still contains an 'any' type in the results field, which contradicts the stated goal of replacing 'any' with explicit types.

Why this matters

Using 'any' here could lead to runtime errors as type checking is bypassed for the results object properties.

Suggested change ∙ Feature Preview

Replace 'any' with 'unknown' or a more specific type based on the actual data structure:

results?: Record<string, unknown>;
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant