Interview kitsBlog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2026 LetsGit.IT. All rights reserved.

TypeScript

Recruitment and knowledge question base. Filter, search and test your knowledge.

Topics

What is TypeScript and why would you use it?

easybasicstypescript
Open question

Answer

TypeScript is a statically typed superset of JavaScript that compiles to JS. It helps catch errors early and improves tooling with types and autocomplete.

What is the any type and why should you avoid it?

easytypesany
Open question

Answer

any disables type checking for a value, which can hide bugs. Use it sparingly and prefer precise types.

What is the void type in TypeScript?

easytypesvoid
Open question

Answer

void represents the absence of a return value and is commonly used for functions that return nothing.

What is the never type and when is it used?

mediumtypesnever
Open question

Answer

never represents values that never occur, such as functions that throw or never return (infinite loops).

What are union types and when do you use them?

easytypesunion
Open question

Answer

Union types allow a value to be one of several types (e.g., string | number). Use them when a value can legitimately have multiple types.

What are intersection types and how do they differ from unions?

mediumtypesintersection
Open question

Answer

Intersection types combine multiple types into one that has all their members (A & B). Unions allow a value to be any one of the listed types.

Type alias vs interface — what’s the difference and when to use each?

mediumtypesinterfacetype-alias
Open question

Answer

Interfaces describe object shapes and can be extended/merged. Type aliases can represent primitives, unions, intersections, and tuples. Use interfaces for public object contracts, type aliases for more flexible compositions.

What are enums in TypeScript and when would you use them?

easyenumstypes
Open question

Answer

Enums define a set of named constants (numeric or string). Use them for a closed set of values where readability matters.

What are tuple types in TypeScript?

easytuplestypes
Open question

Answer

Tuples are fixed-length arrays with known types at each position (e.g., [string, number]).

What is type inference in TypeScript?

mediuminferencetypes
Open question

Answer

Type inference is the compiler’s ability to determine types from context without explicit annotations.

How do optional properties work in TypeScript?

easyoptionaltypes
Open question

Answer

You mark a property with ? to make it optional (e.g., name?: string). It may be present or undefined.

How do you make properties readonly in TypeScript?

easyreadonlytypes
Open question

Answer

Use the readonly modifier on properties or Readonly<T> utility type to prevent reassignment.

What are string literal types in TypeScript?

mediumliteral-typestypes
Open question

Answer

They allow a variable to be only a specific string value or union of specific strings, acting like a constrained enum.

What are template literal types?

mediumtemplate-literaltypes
Open question

Answer

They build new string literal types by combining other literal types using template syntax (e.g., `user_${"id" | "name"}`).

What is a declaration file (.d.ts) used for?

mediumdeclarationsd-ts
Open question

Answer

A declaration file provides type definitions for existing JavaScript code or libraries without implementations.

Name common utility types and what they do.

mediumutility-typestypes
Open question

Answer

Partial makes properties optional, Required makes them required, Readonly makes them immutable, Record maps keys to a type, Pick/Omit select or exclude fields.

How do you compile TypeScript, and what is the difference between .ts and .tsx?

easycompilertsxtsc
Open question

Answer

You compile with tsc (TypeScript compiler). .ts is plain TypeScript, while .tsx allows JSX syntax for React.

What is tsconfig.json and what does strictNullChecks do?

mediumtsconfignull
Open question

Answer

tsconfig.json configures the TypeScript compiler. strictNullChecks treats null/undefined as distinct types and prevents using them where a value is required.

How do type guards work (typeof, in, instanceof, custom predicates)?

hardtype-guardsnarrowing
Open question

Answer

Type guards narrow a union type at runtime checks. typeof checks primitives, in checks properties, instanceof checks classes, and custom predicates return x is Type.

What are generics in TypeScript and why use them?

mediumgenericstypes
Open question

Answer

Generics let you write reusable functions, classes, and types that work with different types while preserving type safety (e.g., T, U). They avoid repetition and keep strong typing.