Type Holes and Placeholders
What you'll learn: How to use never and unknown as temporary placeholders while designing complex type relationships, helping you build types incrementally without breaking your workflow.
The Design Problem
When designing complex type systems, you often don't have all the pieces figured out yet. Maybe you know part of a conditional type should exist, but you're not sure what it should return. Or you're mapping over object properties but haven't decided how to transform certain cases.
Writing incomplete types usually causes compilation errors everywhere, making it hard to work incrementally.
Enter Type Holes
Type holes are temporary placeholders you insert while designing types. Think of them like "TODO" comments, but for the type system itself.
Using never as a Placeholder
Use never when you know a branch should exist but you haven't designed it yet:
type ProcessValue<T> = T extends string
? Uppercase<T>
: T extends number
? never // TODO: figure out number handling
: T extends boolean
? never // TODO: figure out boolean handling
: never;
// You can still work with the string case
type Result = ProcessValue<"hello">; // "HELLO"
never signals "this path exists but produces nothing" — the compiler won't complain, but you'll get never back, reminding you to fill it in.
Using unknown as a Placeholder
Use unknown when you know a type should be something, but you haven't decided what:
type ApiResponse<T> = {
data: T;
meta: unknown; // TODO: design metadata structure
};
// You can use ApiResponse immediately
const response: ApiResponse<string> = {
data: "hello",
meta: { anything: "goes for now" }
};
unknown accepts anything but forces you to narrow before use — a safer "I'll decide later" than any.
Practical Workflow
Start with holes, implement incrementally, replace placeholders as your design clarifies. The compiler stays happy, autocomplete keeps working, and you make progress without getting stuck.
Key Takeaway: Use never and unknown as type-level placeholders during design — they let you build complex type relationships incrementally while maintaining type safety where you have made decisions.