1. Extract function parameter types:
Parameters<T> gives the parameter tuple type of a function. ConstructorParameters<T> does the same for class constructors.
function f(a: string, b: number) {}
type P = Parameters<typeof f>; // [string, number]Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Stripe · Typescript
Practice Typescript questions specifically asked in Stripe interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
9
Tagged for this company + subject
Company
Stripe
View company-wise questions
Subject
Typescript
Explore topic-wise practice
Go through each question and its explanation. Use this page for targeted revision just before your Stripe Typescript round.
Parameters<T> gives the parameter tuple type of a function. ConstructorParameters<T> does the same for class constructors.
function f(a: string, b: number) {}
type P = Parameters<typeof f>; // [string, number]For complete preparation, combine this company + subject page with full company-wise practice and subject-wise practice. You can also explore other companies and topics from the links below.
Tuples model a fixed-length, ordered list where each index can have its own type (e.g., `[string, number]`). They can be mutable or readonly, and tuple elements can even be optional.
type Pair = [string, number]; const p: Pair = ['x', 1]; // Optional element example: type Log = [string, number?];
Use `super(...)` as the first statement in the subclass constructor to run the base class initialization.
class A { constructor(public id: string) {} }
class B extends A { constructor(){ super('b'); } }In mapped types, “-?” removes optional, “+?” adds optional. Similarly, “-readonly” removes readonly and “+readonly” adds it.
type Requiredify<T> = { [K in keyof T]-?: T[K] };
// { a?: number } -> { a: number }TypeScript uses structural typing: two types are compatible if their required members line up, regardless of their declared names. This applies across interfaces, type aliases, and classes treated as shapes.
type Point = { x: number; y: number }
interface Coords { x: number; y: number }
const p: Point = { x: 1, y: 2 };
const c: Coords = p; // ✅ structural compatibilityInterfaces extend and merge naturally and work cleanly with classes. Use type aliases for unions, intersections, and advanced mapped/conditional types.
interface Animal { speak(): void }
class Dog implements Animal { speak() { /*...*/ } }You can reopen a module’s declaration in a `.d.ts` file and add missing types or members. This is great for patching third-party typings without editing `node_modules`.
/* types/lib-augment.d.ts */
declare module 'some-lib' {
export function fancy(): string;
}Express Request is fully generic: `Request<Params, ResBody, ReqBody, Query>`. You can type each part precisely and get IntelliSense everywhere.
import { Request, Response } from 'express';
function handler(req: Request<{id:string}, any, {name:string}, {q?:string}>, res: Response){
res.json({ ok: true });
}Interfaces describe the shape (what methods/properties exist). Classes provide the actual code (how they work) and can implement interfaces.
interface Repo { get(id: string): Promise<string> }
class MemoryRepo implements Repo { async get(id: string){ return id; } }