# TypeScript Fundamentals

> Add static types to JavaScript so the editor catches mistakes before your users do, in both React and Node.js. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/typescript
Last updated: 2026-11-28

Add static types to JavaScript so the editor catches mistakes before your users do, in both React and Node.js.

Intermediate · about 10 hours · difficulty 3/5

Learn first: [JavaScript Fundamentals](https://www.internhack.in/roadmaps/tracks/full-stack/javascript-basics), [npm, Packages and Build Tooling](https://www.internhack.in/roadmaps/tracks/full-stack/npm-and-tooling)

TypeScript is the default for serious full-stack work. Sharing types between frontend and backend means a renamed field breaks the build, not production.

### Basics

- Annotate function parameters and return types; let inference handle most variables.
- Primitive types, arrays, tuples, and literal types like "PENDING" | "PAID".
- **type** and **interface** to describe objects. Either works; be consistent.
- **Optional** properties (?) and **union** types (string | null).

### Narrowing

TypeScript follows your checks. After if (user === null) return, it knows user is defined. Use typeof, in, and **discriminated unions** (a shared status field) to model states like loading, success and error.

### Configuration

tsconfig.json controls strictness. Turn on **strict** from day one; adding it later is painful. Learn what target, module and paths do.

### Using it in practice

Type your API responses, your React props and your database models. Libraries like Prisma and Zod generate types for you, so you rarely write them twice.

### Pitfalls

- Sprinkling any to silence errors. Prefer unknown and narrow it.
- Using as type assertions to lie to the compiler.
- Thinking types exist at runtime. They are erased; incoming data still needs validation.

You are ready to move on when you can convert a small JavaScript project to strict TypeScript with no any and explain each error you fixed.

## Key concepts

- **Type annotations and inference**
- **Object types: type vs interface**
- **Union and literal types**
- **Narrowing and type guards**
- **Discriminated unions**
- **tsconfig and strict mode**
- **any vs unknown**
- **Typing third-party libraries**

## Mini project

Convert your placement offers script to strict TypeScript. Model an Offer type with a status union (APPLIED, SHORTLISTED, OFFERED, REJECTED) and write typed functions to filter and summarise offers.

## Check yourself

If TypeScript types are erased at runtime, what still protects your API from a client sending a string where you expect a number?

## Free resources

- [The TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html) (TypeScript)
- [TypeScript Roadmap](https://roadmap.sh/typescript) (roadmap.sh)
- [Total TypeScript free tutorials](https://www.totaltypescript.com/tutorials) (Total TypeScript)

Previous: [npm, Packages and Build Tooling](https://www.internhack.in/roadmaps/tracks/full-stack/npm-and-tooling) · Next: [Practical TypeScript Patterns](https://www.internhack.in/roadmaps/tracks/full-stack/typescript-patterns)

## More in TypeScript Across the Stack

- [TypeScript Fundamentals](https://www.internhack.in/roadmaps/tracks/full-stack/typescript)
- [Practical TypeScript Patterns](https://www.internhack.in/roadmaps/tracks/full-stack/typescript-patterns)
- [Runtime Validation with Zod](https://www.internhack.in/roadmaps/tracks/full-stack/runtime-validation)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
