TypeScript introduces optional static typing, interfaces, and new language features while building on JavaScriptโs foundation. Letโs explore the syntax!
: type
annotations to enforce specific data types for your variables.
let
and const
declare block-scoped variableslet name: string = "Alex";
function greet(name: string): void
string
, number
, boolean
any
โ disables type checking (avoid if possible)unknown
โ safer alternative to any
void
โ for functions that don't return a valuenull
, undefined