Utility types & strict mode
Partial, Pick, Omit, Record, Readonly and the tsconfig settings every project should use.
TypeScript ships utility types that build new types from existing ones, so you don't repeat yourself:
Partial<T>— all properties optional (good for update forms and PATCH bodies).Pick<T, "a" | "b">/Omit<T, "a">— keep or drop properties.Record<K, V>— an object with keys K and values V.Readonly<T>— every property read-only.ReturnType<typeof fn>— the type a function returns.
tsconfig.json
Turn on "strict": true. It enables strict null checks, so TypeScript forces you to handle null and undefined — the cause of a huge share of real bugs.
Example code
Try it in the TypeScript Playground or with tscinterface User {
id: number;
name: string;
email: string;
password: string;
}
type PublicUser = Omit<User, "password">;
type UserUpdate = Partial<Pick<User, "name" | "email">>;
type CountByCity = Record<string, number>;
const update: UserUpdate = { email: "anu@example.com" }; // name not needed
const counts: CountByCity = { Kochi: 42, Trivandrum: 18 };
function toPublic(u: User): PublicUser {
const { password, ...rest } = u;
return rest;
}
const user: User = { id: 1, name: "Anu", email: "a@x.com", password: "secret" };
console.log(toPublic(user), update, counts.Kochi);
Compiler / program output
{ id: 1, name: 'Anu', email: 'a@x.com' } { email: 'anu@example.com' } 42
Paste the code into the official TypeScript Playground in your browser, or install TypeScript (npm install -D typescript) and run npx tsc --noEmit to type-check. Names are fictional.
Key points
- Partial, Pick, Omit, Record and Readonly build types from types.
- Use Omit to remove sensitive fields such as password.
- Turn on strict mode in tsconfig.json.
- Strict null checks catch undefined bugs early.
Quick check
Which utility type makes every property optional?
Partial<T> marks all properties of T as optional — handy for update payloads.
Practice task
From an interface Job, create JobCard = Pick<Job, "title" | "city"> and JobDraft = Partial<Job>, and write functions that accept each.
Interview corner
Name some TypeScript utility types and when you'd use them.
Partial for update payloads, Pick and Omit for subsets (like removing password from a user), Record for dictionaries, Readonly for immutable data and ReturnType to reuse a function's return type.
What does strict mode enable?
A group of stricter checks, including strictNullChecks (null and undefined must be handled), noImplicitAny (no silent any) and stricter function type checks. New projects should always enable it.
Further reading
Official documentation, linked for deeper study. These are outside sites; this lesson's text is our own.
Original lesson written by the InfoparkDaily team · © 2026 InfoparkDaily · Free to learn — no paid course or subscription.