Issue Type
quicktype-core API (input validation).
Context (Environment, Version, Language)
Input Format: JSON
Output Language: any (tested with TypeScript)
CLI, npm, or app.quicktype.io: npm (quicktype-core)
Version: 25.0.0-pre1 (also reproduces on 24.0.2)
Description
Calling addSource with samples: [] neither throws nor produces an error later — quicktype() happily renders output (168 lines of TypeScript converter boilerplate in my test) for a type that has no evidence at all:
const { quicktype, InputData, jsonInputForTargetLanguage } = require("quicktype-core");
const jsonInput = jsonInputForTargetLanguage("typescript");
await jsonInput.addSource({ name: "X", samples: [] }); // no samples!
const inputData = new InputData();
inputData.addInput(jsonInput);
const result = await quicktype({ inputData, lang: "typescript" });
console.log(result.lines.length); // 168 — full converter scaffolding, no meaningful type
An empty samples array is almost certainly a caller bug (e.g. a glob that matched nothing, or a filtered list that came up empty), and the current behavior masks it.
Expected Behavior
addSource({ name, samples: [] }) should throw a clear error, the same way malformed JSON in a sample already does (Syntax error in input JSON X: ...).
🤖 Filed with Claude Code
Issue Type
quicktype-core API (input validation).
Context (Environment, Version, Language)
Input Format: JSON
Output Language: any (tested with TypeScript)
CLI, npm, or app.quicktype.io: npm (
quicktype-core)Version: 25.0.0-pre1 (also reproduces on 24.0.2)
Description
Calling
addSourcewithsamples: []neither throws nor produces an error later —quicktype()happily renders output (168 lines of TypeScript converter boilerplate in my test) for a type that has no evidence at all:An empty samples array is almost certainly a caller bug (e.g. a glob that matched nothing, or a filtered list that came up empty), and the current behavior masks it.
Expected Behavior
addSource({ name, samples: [] })should throw a clear error, the same way malformed JSON in a sample already does (Syntax error in input JSON X: ...).🤖 Filed with Claude Code