Interview Q&A / TypeScript

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What are indexed access types in TypeScript?

SHORT ANSWER

An indexed access type reads the type of a property using bracket syntax, like User["email"]. You can use a union of keys, or number to get an array's element type, as in string[][number].

Explain it simply

When you write student["name"] in code, you get the value. When you write Student["name"] in a type, you get the type of that property. It is the same idea, one level up.

This helps when a type is already defined somewhere and you want to reuse a piece of it, say the type of an id field, without copying it. If the original changes, your derived type changes with it.

Example

ts
interface User {
  id: number;
  email: string;
  address: { city: string; pin: string };
}

type Id = User["id"];                    // number
type Contact = User["id" | "email"];     // number | string
type City = User["address"]["city"];     // string

// Array element type
type Names = string[];
type Name = Names[number];               // string

// All property types as a union
type AnyValue = User[keyof User];
// number | string | { city: string; pin: string }

What to say in the interview

"Indexed access types, T[K], read a property's type from another type. I use them to reuse part of a type, to dig into nested objects, and with [number] to get an array's element type. T[keyof T] gives a union of all the value types."

#indexed-access#types

Related questions

Practise more TypeScript questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open TypeScript quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.