Skip to content

fix(cli): correct ajv import to resolve TypeScript build error#242

Open
0xAxiom wants to merge 1 commit intomainfrom
fix/ajv-default-import
Open

fix(cli): correct ajv import to resolve TypeScript build error#242
0xAxiom wants to merge 1 commit intomainfrom
fix/ajv-default-import

Conversation

@0xAxiom
Copy link
Copy Markdown
Owner

@0xAxiom 0xAxiom commented May 1, 2026

What

Fixes a TypeScript compilation error in CLI/src/core/stages.ts caused by an incorrect AJV import pattern.

Before:

import Ajv from 'ajv';
// ...
const ajv = new Ajv.default({ allErrors: true, strict: false });

After:

import { Ajv } from 'ajv';
// ...
const ajv = new Ajv({ allErrors: true, strict: false });

Why

The default import import Ajv from 'ajv' combined with new Ajv.default() caused two TypeScript errors depending on which version of AJV types TypeScript resolved:

  1. Property 'default' does not exist on type — when resolving against the root workspace node_modules/ajv (v6, which has no strict option and no .default subclass)
  2. This expression is not constructable — when resolving against CLI/node_modules/ajv (v8 with dist/ built)

npm run type-check exited non-zero before this fix; it exits 0 after.

The named import { Ajv } correctly targets the exported class in AJV v8's type declarations (export declare class Ajv), removing both errors.

Also bumps ajv to ^8.20.0 (latest patch) which ships with a compiled dist/ directory, ensuring TypeScript resolves AJV v8 types rather than hoisting to the root workspace's AJV v6.

Tested

  • npm run type-check passes (exit 0)
  • npm run lint output unchanged (same 53 warnings, 0 errors)
  • No behaviour change at runtime — the named and default imports resolve to the same class in Node.js

🤖 Generated with Claude Code

the ajv import used default import with new Ajv.default() which caused
TypeScript errors after dependency resolution. switching to named import
{ Ajv } and removing the spurious .default call fixes compilation.
bumps ajv to 8.20.0 which ships with a compiled dist directory needed
for correct type resolution in the NodeNext module context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@0xAxiom 0xAxiom requested a review from MeltedMindz as a code owner May 1, 2026 00:00
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