A hands-on practice repository I built to solidify the TypeScript fundamentals covered in an Angular course. Each file focuses on one topic with small, runnable examples that show what TypeScript adds on top of JavaScript: catching type errors at compile time instead of at runtime.
| File | Topic |
|---|---|
FirstLesson.ts |
First steps: compiling a .ts file with tsc |
VariableTypes.ts |
Basic and advanced types: string, number, boolean, arrays, tuples, enums, any |
functions.ts |
Typed parameters and return values, optional and default parameters |
classes.ts |
Classes, constructors and methods |
inhertance.ts |
Inheritance with extends, and public / protected / private access modifiers |
Interface.ts |
Interfaces and optional properties |
Generics.ts |
Generic functions and classes for reusable, type-safe code |
Car.ts · Module.ts |
Modules: exporting a class from one file and importing it in another |
- Clone the repository:
git clone https://github.com/CestnyTR/typescript-basic.git cd typescript-basic - Compile a file and run the output with Node.js:
Or run it directly without a separate compile step:
npx tsc VariableTypes.ts node VariableTypes.js
npx tsx VariableTypes.ts
Some examples intentionally contain type errors (e.g. passing a string where a number is expected) to show how the compiler catches them.
TypeScript · Node.js