References between tasks can be well typed yet point to nonexistent names. Validate membership in the actual set of task IDs as a separate step.
Worked example
type Row = { task: string; needs: string[] };
const rows: Row[] = [
{ task: "design", needs: [] },
{ task: "build", needs: ["design"] },
{ task: "test", needs: ["build"] },
{ task: "ship", needs: ["build", "test"] },
];
const result = [...new Set(rows.flatMap((r) => r.needs))].filter(
(name) => !rows.some((r) => r.task === name),
);
console.log(JSON.stringify(result, null, 2));Result
[]Implementation notes
Checking for missing targets and detecting cycles are different graph checks. A complete set of task names can still contain a circular dependency.
Try it yourself
Add a missing prerequisite and a valid task with no prerequisites.
Open the TypeScript example →Editorial date July 23, 2026 · Published December 6, 2026