TypeScript Fundamentals
TypeScript adds a static type checker to JavaScript. You describe the values your code expects, then get editor feedback and errors before the JavaScript runs.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — TypeScript Fundamentals
TypeScript is JavaScript wearing a very diligent clipboard. It reads the program before it runs, compares the values you say you expect with the operations you perform, and points at incompatible combinations. Then it removes its own notes and lets JavaScript do the actual running. The clipboard does not become a security guard merely because it was carrying a clipboard.
That explains the important surprise. A type annotation describes a value; it does not convert one. An assertion asks the checker to trust a claim; it does not inspect a network response, parsed document, or user input. Treat incoming data as unknown, which means it must be checked before application logic treats it as a known shape. Runtime validation and static types are colleagues, not substitutes who have secretly agreed to cover each other's shifts.
Most local values need less ceremony than they appear to demand. The checker can infer a type from an initial value, a call, or nearby context. Save annotations for public contracts and deliberate boundaries. For alternatives, use a union: each valid state has its own shape. A shared literal property, called a discriminant, tells the checker which state survived a runtime check. This is how a loading result avoids claiming to be ready and failed at the same time, which is a fine quality in both software and umbrellas.
Generics keep a relationship intact when the concrete type is not known yet. A function that returns the first item from a list should return a string for a string list and a number for a number list. any abandons that relationship. unknown waits for evidence. The distinction sounds fussy until an unexpected value enters a path that was certain it knew better.
Read the intro when you need the complete map of types, narrowing, assertions, and strict settings. Use the slides for the flow from source code to JavaScript runtime. Keep the cheatsheet nearby when choosing a union, guard, generic, or compiler option. Then run the practice reference and exercise: they make the boundary between a clean type check and a real runtime value impossible to miss.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html
Supports
- TypeScript as a static type checker for JavaScript
- Type erasure and JavaScript runtime behavior
- Static checking finding incompatible operations before execution
- https://www.typescriptlang.org/docs/handbook/2/everyday-types.html
Supports
- Primitive, array, object, union, annotation, and inference behavior
- Contextual typing for callback parameters
- Structural typing of object shapes
- Type assertions and their lack of runtime behavior
- Null and undefined behavior under strict null checks
- https://www.typescriptlang.org/docs/handbook/2/narrowing.html
Supports
- Control-flow analysis and type guards
- Narrowing with typeof, equality, property checks, and instanceof
- Discriminated unions and exhaustive never checks
- https://www.typescriptlang.org/docs/handbook/2/functions.html
Supports
- Function parameter and return contracts
- Optional parameters and void behavior
- unknown as a safer alternative to any
- Guidance for useful generic type parameters
- https://www.typescriptlang.org/docs/handbook/2/generics.html
Supports
- Generics as reusable components across multiple types
- Type inference and constraints in generic relationships
- https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html
Supports
- Structural type-system compatibility
- Interfaces as named object shapes
- https://www.typescriptlang.org/tsconfig/strict.html
Supports
- strict as a family of stronger type-checking options
- Potential for newer compiler versions to report additional errors
- https://www.typescriptlang.org/tsconfig/
Supports
- Compiler options for emit, target, modules, resolution, and library declarations
- https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
Supports
- Declaration files describing existing JavaScript APIs
- Package-provided declarations and DefinitelyTyped packages
- https://github.com/dzharii/awesome-typescript
Supports
- Discovery of TypeDoc, Zod, type-fest, and ts-node as TypeScript ecosystem resources
- https://typedoc.org/
Supports
- TypeDoc converting TypeScript source comments into HTML documentation or a JSON model
- Documentation generation from exported APIs and entry points
- https://zod.dev/
Supports
- Zod schemas validating runtime data
- Static type inference from schemas
- https://github.com/sindresorhus/type-fest
Supports
- Collection of reusable TypeScript utility types
- Documented object, union, and deep transformation utilities
- https://typestrong.org/ts-node/docs/
Supports
- TypeScript execution in Node.js
- Connection between the TypeScript compiler and Node module loading
- https://valibot.dev/
Supports
- Runtime schemas that validate unknown data and infer TypeScript types
- Modular runtime validation for TypeScript applications
- https://www.typescriptlang.org/docs/handbook/compiler-options.html
Supports
- TypeScript compiler command-line and configuration options
- Checking with no emitted JavaScript
- https://devblogs.microsoft.com/typescript/announcing-typescript-1-0/
Supports
- TypeScript 0.8 release in October 2012
- TypeScript 1.0 announcement in April 2014
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-4.html
Supports
- Union types, type guards, and aliases in TypeScript 1.4
- https://devblogs.microsoft.com/typescript/announcing-typescript-2-0/
Supports
- strictNullChecks and control-flow-based type analysis in TypeScript 2.0
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
Supports
- Conditional types and utility types in TypeScript 2.8
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html
Supports
- Project references and build mode in TypeScript 3.0
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html
Supports
- Variadic tuple types and labeled tuple elements in TypeScript 4.0
- https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/
Supports
- Standard decorators and const type parameters in TypeScript 5.0
- https://github.com/microsoft/TypeScript/wiki/Performance
Supports
- Project boundaries and performance guidance for TypeScript builds and editing
- extendedDiagnostics for identifying compiler work
- https://github.com/microsoft/TypeScript/wiki/Performance-Tracing
Supports
- generateTrace for investigating TypeScript compilation performance
