Web Development
0/4 sections
0%

TypeScript

TypeScript is a typed superset of JavaScript that compiles to plain JS. It adds static types, interfaces, and advanced OOP features to catch errors at compile time.

TypeScript's value compounds with codebase size. On small projects, the setup overhead can feel disproportionate. On codebases with 50+ files and multiple contributors, the type system becomes the most effective documentation and refactoring tool available, making large-scale changes safe and self-documenting.

Strict mode is not optional for serious TypeScript projects. Enabling strictNullChecks, noImplicitAny, and strictPropertyInitialization eliminates entire categories of runtime errors. The initial friction of fixing type errors pays dividends immediately in fewer production bugs and more confident refactoring.

TypeScript's utility types (Partial, Required, Pick, Omit, Record, Awaited) are productivity multipliers. Rather than duplicating type definitions across the codebase, these mapped types derive new types from existing ones automatically, keeping the type system synchronized with implementation changes.

Generic constraints are where TypeScript's power becomes most apparent. Writing functions and components that accept a range of types while guaranteeing type safety at call sites enables reusable building blocks that are both flexible and correct - a combination difficult to achieve in dynamically typed languages.

Relevant to My Experience

How this topic connects to real projects and companies

Experience

TypeScript adoption in large codebases

Related Projects

1TypeScript Fundamentals

typescript
// Basic types
let name: string = "Sufi";
let age: number = 30;
let active: boolean = true;
let anything: unknown = "start";  // safer than 'any'
let nothing: void = undefined;
let missing: undefined = undefined;
let empty: null = null;

// Arrays let nums: number[] = [1, 2, 3]; let strs: Array = ["a", "b"]; let tuple: [string, number] = ["Alice", 30];

// Union & Intersection type StringOrNumber = string | number; type AdminUser = User & Admin;

// Literal types type Direction = "north" | "south" | "east" | "west"; type StatusCode = 200 | 400 | 401 | 403 | 404 | 500;

// Type assertions const canvas = document.getElementById("c") as HTMLCanvasElement; ```

2Interfaces & Types

typescript
// Interface
interface User {
  readonly id: string;
  name: string;
  email: string;
  age?: number;              // optional
  address: {
    city: string;
    country: string;
  };
}

// Type alias type Point = { x: number; y: number; };

// Interface extension interface AdminUser extends User { role: "admin"; permissions: string[]; }

// Generics function identity(arg: T): T { return arg; }

interface ApiResponse { data: T; status: number; message: string; }

async function fetchUser(id: string): Promise> { const res = await fetch(/api/users/${id}); return res.json(); } ```

3Advanced TypeScript

typescript
// Utility Types
type Partial<T> = { [K in keyof T]?: T[K] };
type Required<T> = { [K in keyof T]-?: T[K] };
type Readonly<T> = { readonly [K in keyof T]: T[K] };
type Pick<T, K extends keyof T> = { [P in K]: T[P] };
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type Record<K extends string, V> = { [P in K]: V };

// Conditional types type IsArray = T extends any[] ? true : false; type Unwrap = T extends Promise ? U : T;

// Template literal types type EventName = on${Capitalize}; type CSSUnit = ${number}px | ${number}rem | ${number}%;

// Discriminated unions type Shape = | { kind: "circle"; radius: number } | { kind: "rect"; width: number; height: number } | { kind: "triangle"; base: number; height: number };

function area(shape: Shape): number { switch (shape.kind) { case "circle": return Math.PI * shape.radius ** 2; case "rect": return shape.width * shape.height; case "triangle": return 0.5 * shape.base * shape.height; } } ```

4Advanced Type Patterns

typescript
// ── Mapped types ──────────────────────────────────────
type Mutable<T>   = { -readonly [K in keyof T]: T[K] };
type Deep<T>      = T extends object
    ? { [K in keyof T]: Deep<T[K]> }
    : T;
type Nullable<T>  = { [K in keyof T]: T[K] | null };
type ApiResponse<T> = { data: T; error: null } | { data: null; error: string };

// ── Infer ───────────────────────────────────────────── type ReturnType any> = T extends (...args: any) => infer R ? R : never;

type PromiseValue = T extends Promise ? V : never;

type FirstArg any> = T extends (first: infer F, ...rest: any) => any ? F : never;

// ── Discriminated unions for exhaustive handling ────── type Shape = | { kind: 'circle'; radius: number } | { kind: 'rect'; width: number; height: number } | { kind: 'triangle'; base: number; height: number };

function area(shape: Shape): number { switch (shape.kind) { case 'circle': return Math.PI * shape.radius ** 2; case 'rect': return shape.width * shape.height; case 'triangle': return 0.5 * shape.base * shape.height; // TypeScript exhaustiveness if you add a Shape variant // without a case, TypeScript errors here: default: return shape satisfies never; } }

// ── Branded types prevent mixing same primitives ──── type UserId = string & { readonly __brand: 'UserId' }; type ProductId = string & { readonly __brand: 'ProductId' };

function createUserId(id: string): UserId { return id as UserId; }

declare function getUser(id: UserId): User; const pid = createProductId('prod-1'); getUser(pid); // TypeScript ERROR cannot pass ProductId as UserId ```

Explore the Full Portfolio

This is the complete portfolio of Sufi Khan Sulaiman, a technology leader specialising in B2B commerce and digital automation. Start from the Home page for the overview, then move through two decades of career experience across FLIR Systems, Lorex Technology, and 1c Platform, and the full catalogue of project case studies spanning headless commerce migrations, AI recommendation engines, and multi-channel fulfilment systems.

The skills and certifications page maps the technical and leadership capabilities behind the work, while the articles and the knowledge base break down the thinking into actionable frameworks. For hands-on learning, the tutorials and applications sections cover practical builds from front-end fundamentals to full-stack web apps.

For consulting engagement, the expertise page outlines service offerings, the ecommerce hub covers platform architecture and automation strategy, and the ecommerce guide (PDF) is a downloadable 55-page field manual. When you are ready to talk, the contact page is the direct line.