Bug Report
jsonSchemaToType from @ark/json-schema throws a ParseError when given a schema that combines type: "string" with enum. This is a common JSON Schema pattern (the type annotation is redundant but valid per spec when all enum values are strings).
Package
@ark/json-schema v0.0.4
Repro
import { jsonSchemaToType } from "@ark/json-schema"
// ✅ works
jsonSchemaToType({ type: "string" })
// ✅ works
jsonSchemaToType({ enum: ["stable", "latest"] })
// ❌ throws: ParseError: Intersection of string and object results in an unsatisfiable type
jsonSchemaToType({ type: "string", enum: ["stable", "latest"] })
// ❌ also throws (default + enum + type)
jsonSchemaToType({ type: "string", enum: ["stable", "latest"], default: "latest" })
// ❌ also throws when nested inside an object property
jsonSchemaToType({
type: "object",
properties: {
mode: { type: "string", enum: ["append", "replace"] }
}
})
Expected behavior
{ type: "string", enum: ["stable", "latest"] } should produce the equivalent of type("'stable' | 'latest'"). Per JSON Schema spec, when type and enum are combined, the type annotation is informational — the enum constraint already restricts the valid values.
Actual behavior
ParseError: Intersection of string and object results in an unsatisfiable type
at throwError (node_modules/@ark/util/out/errors.js:5:11)
at applyMorphsAtPath (node_modules/@ark/schema/out/shared/traversal.js:184:28)
at applyQueuedMorphs (node_modules/@ark/schema/out/shared/traversal.js:166:22)
at finalize (node_modules/@ark/schema/out/shared/traversal.js:109:18)
at <anonymous> (node_modules/@ark/json-schema/out/object.js:103:20)
The library appears to process type: "string" and enum as separate constraints and then intersect them, producing string & object = unsatisfiable, rather than recognising that enum with all-string values is already a string subtype.
Context
Encountered while trying to use jsonSchemaToType with the Claude Code settings JSON Schema, which uses { type: "string", enum: [...] } for several properties (autoUpdatesChannel, effortLevel, forceLoginMethod, spinnerVerbs.mode, teammateMode).
Bug Report
jsonSchemaToTypefrom@ark/json-schemathrows aParseErrorwhen given a schema that combinestype: "string"withenum. This is a common JSON Schema pattern (thetypeannotation is redundant but valid per spec when all enum values are strings).Package
@ark/json-schemav0.0.4Repro
Expected behavior
{ type: "string", enum: ["stable", "latest"] }should produce the equivalent oftype("'stable' | 'latest'"). Per JSON Schema spec, whentypeandenumare combined, thetypeannotation is informational — theenumconstraint already restricts the valid values.Actual behavior
The library appears to process
type: "string"andenumas separate constraints and then intersect them, producingstring & object= unsatisfiable, rather than recognising thatenumwith all-string values is already a string subtype.Context
Encountered while trying to use
jsonSchemaToTypewith the Claude Code settings JSON Schema, which uses{ type: "string", enum: [...] }for several properties (autoUpdatesChannel,effortLevel,forceLoginMethod,spinnerVerbs.mode,teammateMode).