Skip to content

jest.config.ts: diagnostics: false suppresses all TypeScript type checking in tests #28

@k7lim

Description

@k7lim

Problem

jest.config.ts was updated to add diagnostics: false to the ts-jest transform config as a workaround for a pre-existing type error in src/bin/cli.ts. This silently disables TypeScript type checking across the entire test suite — type errors in test files won't be surfaced by pnpm test.

Root cause

src/bin/cli.ts passes 0 (integer) as the third element of the maxSvgColors command tuple:

[
  Commands.maxSvgColors,
  'Max colors for SVG conversion of simple images (default: 16). Requires --optimize.',
  0,
]

The args library types expect string | boolean | undefined for the default value, so 0 is a type error. ts-jest caught this and refused to compile, blocking the test suite.

Fix

Change the default from 0 to undefined (or omit it entirely) in the commands array, and update the maxSvgColors flag resolution in run() accordingly:

// In commands array — omit the default or use undefined
[
  Commands.maxSvgColors,
  'Max colors for SVG conversion of simple images (default: 16). Requires --optimize.',
],

// Flag resolution already handles missing/zero correctly:
const maxSvgColors = typeof flags.maxSvgColors === 'number' && flags.maxSvgColors > 0
  ? flags.maxSvgColors
  : undefined

Once the type error is fixed, remove diagnostics: false and strict: false from jest.config.ts to restore full type checking.

Files

  • src/bin/cli.ts — fix the 0 default
  • jest.config.ts — remove diagnostics: false and strict: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions