colinhacks/zod · error · Error
Unsupported type: ${type}
Error message
Unsupported type: ${type} What it means
Thrown by convertTypeSpecificSchema's default switch case when the JSON Schema `type` is not one of the handled values. The converter supports a fixed set of primitives and rejects anything else rather than silently producing z.unknown().
Source
Thrown at packages/zod/src/v4/classic/from-json-schema.ts:527
// Apply constraints
if (typeof schema.minItems === "number") {
arraySchema = arraySchema.min(schema.minItems);
}
if (typeof schema.maxItems === "number") {
arraySchema = arraySchema.max(schema.maxItems);
}
zodSchema = arraySchema;
} else {
// No items specified - array of any
zodSchema = z.array(z.any());
}
break;
}
default:
throw new Error(`Unsupported type: ${type}`);
}
return zodSchema;
}
function convertSchema(schema: JSONSchema.JSONSchema | boolean, ctx: ConversionContext): ZodType {
if (typeof schema === "boolean") {
return schema ? z.any() : z.never();
}
// Convert base schema first (ignoring composition keywords)
let baseSchema = convertBaseSchema(schema, ctx);
const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
// Process composition keywords LAST (they can appear together)
// Handle anyOf - wrap base schema with union
if (schema.anyOf && Array.isArray(schema.anyOf)) {
const options = schema.anyOf.map((s) => convertSchema(s, ctx));View on GitHub (pinned to 912f0f51b0)
Solutions
- Correct the `type` to a supported primitive (object, array, string, number, integer, boolean, null).
- If the type is genuinely unsupported, drop the `type` keyword and rely on other constraints (enum/const/composition) instead.
- Pre-process to map or strip unknown types before conversion.
Example fix
// before
{ "type": "interger" } // typo
// after
{ "type": "integer" } Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = new Set(["object","array","string","number","integer","boolean","null"]);
function assertSupportedType(schema: any) {
const t = schema?.type;
const types = Array.isArray(t) ? t : [t];
for (const ty of types) if (ty != null && !SUPPORTED.has(ty)) throw new Error(`Unsupported type: ${ty}`);
} Type guard
function isSupportedType(t: unknown): boolean {
return t == null || ["object","array","string","number","integer","boolean","null"].includes(t as string);
} Prevention
- Validate `type` against the supported set before conversion.
- Spell-check types and lint against typos like 'interger'.
- Drop unknown types or map them to `any` deliberately.
When it happens
Trigger: A schema with `type` set to a value outside the supported set — e.g. custom/extensional types, misspelled types (`'interger'`), or future draft values the converter does not yet know.
Common situations: Schema authoring typos; consuming schemas with vendor extensions; mixing OpenAPI-flavoured types; new JSON Schema draft keywords.
Related errors
- not is not supported in Zod (except { not: {} } for never)
- unevaluatedItems is not supported
- unevaluatedProperties is not supported
- Conditional schemas (if/then/else) are not supported
- dependentSchemas and dependentRequired are not supported
AI-assisted analysis of colinhacks/zod@912f0f51b0 (2026-08-03).
Data as JSON: /data/errors/67b843a255d1bf82.json.
Report an issue: GitHub.