Skip to content

types.ts: LoopCliConfig.maxPrompts docstring claims 'null/undefined' is unlimited, but the type only permits 'undefined' #79

@joewalker

Description

@joewalker

Observed behavior

The docstring on LoopCliConfig.maxPrompts in src/types.ts reads:

/**
 * Maximum number of prompts to process. Unlimited when null/undefined.
 */
readonly maxPrompts?: number;

The doc says the field is unlimited when set to null or undefined. But the field's TypeScript type is number | undefined (optional number), so a strict TypeScript caller cannot legally pass null. The implementation in loop.ts does coalesce with ?? Infinity, which would accept null at runtime, but the type contract forbids it.

This is a small TS/JS hazard: a JavaScript caller reading the JSDoc might set maxPrompts: null and have it work; a TypeScript caller doing the same will see a compile error and assume the JSDoc is wrong.

Expected behavior

Either:

  1. The docstring should drop the mention of null and read "Unlimited when omitted" (matching the JSON schema in schema/loop-the-loop.schema.json, which also requires an integer); or
  2. The type should be widened to number | null | undefined if null is genuinely supported.

Option 1 matches existing intent (the JSON schema requires integer >= 0, not nullable).

Minimal reproduction

Open src/types.ts at line 86 and compare the JSDoc with the field type immediately below it. Also note that schema/loop-the-loop.schema.json declares maxPrompts as a non-nullable integer.

Suggested fix

Change the docstring to "Maximum number of prompts to process. Unlimited when omitted."

Metadata

Metadata

Assignees

No one assigned

    Labels

    S4Clean-ups or nits with low behavioral riskbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions