TypeScript Survival Guide

Favorite typescript videos

035 — #13 Understanding Type Alias | TypeScript Basics & Data Types | A Complete TypeScript Course

The lecture answers "what is a type alias": a custom name for a type, declared with the `type` keyword, usable everywhere the original type was. Three reuse cases build the argument. First, the trivial `type StringType = string` shows the mechanics (hovering the variable still shows `string`). Second, the previous lecture's `printStatus` union `string | number` becomes `type StringOrNumber = strin

Video: 035 · #13 Understanding Type Alias | TypeScript Basics & Data Types | A Complete TypeScript Course · watch · ~10:47 · procademy

Source: this is a written companion to the video. Part of the Favorite TypeScript Videos curated path. Narrative mined from transcript + visual captions (dn9aUaZ2noE-narrative.md).

The lecture answers one question: what is a type alias. “Type alias simply means providing a custom name for your type” — declared with the type keyword, usable everywhere the original type was. It can equally be called a custom type: assign a type once, reuse it at multiple places.

course title slide for the TypeScript fundamentals lecture

the trivial alias that shows the mechanics

The editor opens on the smallest possible example:

type StringType = string;
let str: StringType = "some string value"; // hover type: string

Hovering the variable still shows string — the alias changed nothing the checker sees. That is the point: aliases are a write-once editing convenience, invisible at runtime.

one name for the printStatus union

Next the lecture-11 printStatus function comes back, with the boolean/null members trimmed so code is string | number. The union gets a name:

type StringOrNumber = string | number;
function printStatus(message: string, code: StringOrNumber) {
	/* ... */
}

Hovering code shows StringOrNumber, expanding to string | number. Compiling confirms both calls still log — same behavior, shorter annotation.

one word for three literals

The lecture-12 role parameter gets the same treatment: the "admin" | "read" | "read-write" annotation is cut out of the parameter and pasted into type RoleType = ..., and the parameter becomes role: RoleType. Passing "ABC" still errors immediately; passing "admin" still logs “you have admin permission on this site.”

a shared shape for two functions

The finale is an object alias shared by two functions and one object:

type User = { firstname: string; lastname: string; age: number };

function getFullName(user: User) {
	return user.firstname + " " + user.lastname;
}
function isEligibleForVoting(user: User) {
	return user.age >= 18;
}
const user: User = { firstname: "John", lastname: "Smith", age: 32 };
console.log(getFullName(user)); // John Smith
console.log(isEligibleForVoting(user)); // true (32 >= 18)

Without the alias, the full object annotation would be repeated on every parameter; with it, the shape is declared once. IntelliSense confirms the linkage: after typing user: User, the editor suggests firstname, lastname, and age.

Prev: 034 — #12 Literal Type in TypeScript | TypeScript Basics & Data Types | A Complete TypeScript Course · Next: 036 — #14 Function Return Type | TypeScript Basics & Data Types | A Complete TypeScript Course

Transcript notes: StringType / StringOrNumber / RoleType / User (not “string type”, “rule type”, “user in caps”), admin (not “Edwin”), 32 > 18 (not 80), tsc compile (not “.ts file” steps). Alias declarations with the John Smith / 32 demo values and the compile-and-run confirmations.