You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project provides a comprehensive overview of commonly used TypeScript methods and features, grouped by their functionality, along with brief descriptions and usage examples.
Basic Types
TypeScript Type
Description
Example
boolean
Represents true/false values
let isDone: boolean = false;
number
Represents numeric values
let decimal: number = 6;
string
Represents text values
let color: string = "blue";
array
Represents an array of values
let list: number[] = [1, 2, 3];
tuple
Represents an array with fixed number of elements of specific types
let x: [string, number]; x = ["hello", 10];
enum
Represents a collection of related values
enum Color {Red, Green, Blue}; let c: Color = Color.Green;
any
Represents any type
let notSure: any = 4; notSure = "maybe a string instead";
void
Represents the absence of a type
function warnUser(): void { console.log("This is my warning message"); }
class Animal { move(distanceInMeters: number = 0) { console.log(\Animal moved ${distanceInMeters}m.`); } } class Dog extends Animal { bark() { console.log('Woof! Woof!'); } }`
super
Calls the constructor of the base class
class Dog extends Animal { constructor(name: string) { super(name); } }
Public, Private, and Protected Modifiers
Access control keywords for class members
class Animal { private name: string; public constructor(theName: string) { this.name = theName; } }
This document provides a quick reference to commonly used TypeScript methods and features. For more detailed information, refer to the TypeScript Handbook.
About
This repository provides a comprehensive overview of commonly used TypeScript methods and features, grouped by their functionality, along with brief descriptions and usage examples.