Skip to content

Fundamental Types

Jorge Castro edited this page Nov 10, 2025 · 1 revision

Primitives (string, number, boolean) and Arrays

  • Refer to the Variables with Type Annotations example.

Type any

let data: any = { country: 0 };
data.process();
data();
data.name = 100;
data = "hello";
const age: number = data;

Functions

With type annotations

function isPhraseExceedingLimit(phrase: string, limit: number): boolean {
  return phrase.length > limit;
}

Returning promises

Promise<T> is a built-in type.

async function getFavoriteNumber(): Promise<number> {
  return 26;
}

Anonymous functions

const names = ["Alice", "Bob", "Eve"];

names.forEach((name) => {
  console.log(name.toUpperCase());
});

Clone this wiki locally