Dev Helpers

TypeScript / Typed collections

Check for dangling dependency names

Dev Helpers · July 23, 2026

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

Related articles

Initialize a typed Set

A generic Set keeps insertions consistent across the lifetime of the collection. Explicit type arguments are especially useful when the set starts empty.

Reject fractional cent amounts

A numeric type cannot by itself guarantee whole cents. Validate integrality where money enters the typed part of the application.