Jobs worldwide · Free to apply

Back to All Career Guides
Interview Preparation8 min readPublished Nov 24, 2026

TypeScript Interview Questions and Answers for 2026

The exact TypeScript questions Pakistani developers face in 2026 interviews, with worked answers you can say out loud and a two-week plan to get ready.

Sheikh Muqtasid
Software Engineer
Quick answer

TypeScript interviews in Pakistan test how you reason about types, not whether you can recite definitions. Know any versus unknown, interface versus type, and generics cold, and fix strict-mode errors by narrowing rather than casting. Type API responses, handle nulls, and say your reasoning out loud while you code.

Key Takeaways & Executive Summary
  • Interviewers test how you reason about types, not whether you can recite definitions.
  • Know any versus unknown, interface versus type, and generics cold before the interview.
  • Strict mode and narrowing cause most of the real mistakes in live coding.
  • Say your reasoning out loud while you type, because that is what gets scored.
  • Two focused weeks of daily practice beats a month of reading documentation.

1. What TypeScript Interviews Actually Test

Picture this. You open a Next.js job on Rozee in Lahore, the listing asks for TypeScript, and the first interview round is a shared editor with a broken type. No multiple choice. No theory quiz. Just you, a red squiggle, and an interviewer watching how you think. That is the real test in 2026, and it surprises a lot of JavaScript developers who studied TypeScript like a vocabulary list. The interviewer does not care whether you can define a mapped type from memory. They care whether you can look at a type error, work out what the compiler is complaining about, and fix it without turning everything into any. Three things get checked again and again. First, can you model real data, like a user object that sometimes has a phone number and sometimes does not, without lying to the compiler? Second, can you read someone else's types and spot where they are too loose or too strict? Third, can you explain a trade-off, such as why you picked an interface over a type alias for a public API? If you can do those three things, the rest is detail. If you cannot, no amount of memorised syntax will save you. So prepare by fixing real errors, not by rereading the handbook for the fifth time.

What is the difference between any and unknown?

Question: what is the difference between any and unknown? Worked answer: any switches the type checker off, so you can call any method on it and the compiler stays quiet until the code crashes at runtime. Unknown switches the checker on, because you must narrow it with a check, such as typeof value === "string", before you can use it. Say that, then add the rule you follow: use unknown for data from an API or a form, and treat any as a temporary patch you remove before a pull request. Question: interface or type alias, which do you use? Worked answer: use an interface for an object shape that other code might extend, like a User or an ApiResponse, because interfaces merge and read cleanly in error messages. Use a type alias for unions, tuples, and mapped types, like type Status = "active" | "paused", because an interface cannot express those. Question: what does the question mark do in user?: string? Worked answer: it marks the property as optional, so the type becomes string or undefined, and you must handle the undefined case before calling a string method on it. Interviewers love that follow-up, because it leads straight into narrowing.

3. Generics, Utility Types and Type Inference in Practice

Question: write a function that returns the first item of an array, typed properly. Worked answer: function firstItem<T>(items: T[]): T | undefined { return items[0]; }. The T stands for whatever type the caller passes in, so firstItem([1, 2]) returns number or undefined, and firstItem(["a"]) returns string or undefined. If you wrote the return type as T alone, you lied, because an empty array returns undefined. Interviewers notice that. Question: what does Pick do? Worked answer: Pick takes an existing type and keeps only the keys you name. Pick<User, "id" | "name"> builds a smaller type with just id and name, which is exactly what you want for a list view that should never receive a password hash. Omit does the opposite, and Partial makes every property optional, which suits a PATCH request body. Question: how does TypeScript infer the type of const user = { age: 30 }? Worked answer: it infers age as number, not 30, unless you use as const, which narrows it to the literal 30. That distinction matters when you pass the object into a function that expects a specific literal. Learn these four utilities by using them in a real project, not by listing them: Pick, Omit, Partial, and Record.

What strict-mode errors trip people up?

Open tsconfig.json in any serious Pakistani startup codebase and you will find strict set to true. That one line turns on strictNullChecks, noImplicitAny, and strictFunctionTypes, and it is where most candidates lose points. Take this line: const name = user.name.toUpperCase(). If user can be null, strict mode stops you, and the fix is not a non-null assertion. The fix is a guard: if (!user) return; then use user.name. The exclamation mark, user!.name, tells the compiler to trust you, and interviewers treat it as a smell, because it moves a compile-time error into a runtime crash. Narrowing is the skill behind the fix. A union type like string | number narrows after a typeof check. An object with a kind field narrows after you check kind === "invoice". A value checked with Array.isArray narrows to an array. Practice by turning strict on in a small project and fixing every error without using any, without using a non-null assertion, and without casting to an unknown type first. It feels slow for a day. Then it becomes automatic. In the interview, when you hit a red squiggle, say what the type is, say what it needs to be, and narrow it. That sentence alone shows more skill than a perfect answer delivered in silence.

5. Live Coding in TypeScript: How Interviewers Score You

Here is a task you will meet in some form: build a function that fetches a list of jobs from an API, filters out expired ones, and returns them sorted by posted date. The interviewer is scoring four things, and only one of them is whether the code runs. First, did you type the API response instead of calling it any? A type like interface Job { id: string; title: string; postedAt: string; expiresAt: string | null } earns points before you write a line of logic. Second, did you handle the null expiry date? Expired means expiresAt is not null and the date has passed, and forgetting the null check is the most common fail. Third, did you keep the function pure, taking the jobs in and returning new ones out, instead of mutating the input array with sort? Sorting mutates in place, so copy first with a spread or slice. Fourth, did you talk while you worked? Say the plan in one sentence, name the edge case, then type. If you go quiet for three minutes and then present perfect code, the interviewer still does not know how you think. If you talk through a small mistake and fix it, they do. Keep your editor habits clean too: rename a variable instead of leaving it as data2, and delete a dead line instead of leaving it commented out.

6. A Two-Week Plan That Fits Around a Job

You do not need a month off work to prepare. You need fourteen days with one focused hour a day, and a rule: every day ends with code you typed, not a video you watched. Days one to three, turn strict mode on in a small project and fix every error by narrowing, not by casting. Write down each error and its fix in a notebook, because the same ten errors repeat in interviews. Days four to six, rebuild three small utilities from scratch: a typed fetch wrapper that takes a URL and returns a typed result, a filter function with a generic, and a form state type that uses Partial for updates. Days seven to nine, practise out loud. Open the TypeScript playground, pick a question from this guide, and answer it while a timer runs for three minutes. Record yourself on your phone if you can stand it, because hearing your own pauses shows you where you ramble. Days ten to twelve, do two mock live-coding tasks with a friend, or alone with a 30-minute timer: type an API response, filter it, and sort it. Days thirteen and fourteen, review your notebook, redo the questions you fumbled, and read the job description again so your examples match the stack the company actually uses.

Frequently Asked Questions

Is TypeScript still worth learning in 2026 if I already know JavaScript?

Yes, because most React, Next.js, and Node.js roles listed on Rozee and LinkedIn for Pakistan now ask for it, and the interview will test it directly. JavaScript alone still gets you interviews, but TypeScript is the skill that decides the technical round.

What is the single most asked TypeScript interview question?

The difference between any and unknown, followed closely by interface versus type alias. Answer both with a concrete example and a rule for when you use each, not just a definition.

Should I ever use any in an interview?

Only as a stated temporary step while you work out the real type, and say so out loud. If your final answer still contains any, the interviewer will read it as a gap in your typing, not as pragmatism.

How much TypeScript do I need for a junior role in Pakistan?

Enough to type an API response, handle optional and nullable fields, use generics in a simple helper, and fix strict-mode errors by narrowing. You do not need advanced mapped types or declaration files for a junior interview.

Ready to Put These Strategies into Practice?

Explore thousands of software, remote, and IT vacancies actively hiring today.

Browse Openings

Recommended Career Playbooks

Interview Preparation

What to Do When You Get Completely Stuck in a Live Coding Interview

The 5 emergency mental shifts to recover gracefully, communicate your way out of a dead end, and save your interview.

Read Article
Interview Preparation

How to Pass Modern Software Engineering Interviews: A Practical, Low-Stress Guide

What happens in live coding sessions, system design interviews and behavioral questions, and how to prepare for each one.

Read Article
Interview Preparation

SQL Interview Questions and Answers

The SQL questions Pakistani employers actually ask, with worked answers for JOINs, GROUP BY, window functions, and the live tasks that catch candidates out.

Read Article
Interview Preparation

Python Interview Questions and Answers

The Python questions that decide interviews in Pakistan, with worked answers for lists, decorators, generators, and the live coding tasks employers actually set.

Read Article