TypeScript for JavaScript developers: the 10% of TypeScript you actually need — types, interfaces, generics and narrowing, with real code.
▶ Full written tutorial (free): https://generalistprogrammer.com/tuto...
You already know 90 percent of TypeScript, because TypeScript is JavaScript. Every line of
JavaScript you have ever written is already valid TypeScript. So this is not a from-scratch
language course. It is the other 10 percent for javascript developers: the small set of things
that are actually new, taught with correct, copy-pasteable code on screen the whole way.
This tutorial is friendly for anyone who already writes JavaScript, and there is a free written
guide linked below with every snippet.
The only 10 percent you do not already know, step by step:
Type annotations: a colon and a type after a name, number arrays, and typed function
parameters and return types. Plus inference, so you often do not annotate at all.
Union and literal types: one pipe means either type, literal unions act like a free enum, and
you narrow them with typeof.
Interfaces versus type aliases: interface for object shapes you may extend, type for unions,
tuples, and primitives, with optional and readonly fields.
Functions: optional parameters, default parameters, rest parameters, the void return type, and
naming a whole function signature as a type.
Generics: a type as a parameter, on both functions and object shapes, with zero duplication.
Narrowing and type guards: typeof, the in operator, isArray, and truthiness checks, plus why
you should reach for unknown over any. Any opts out of checking; unknown forces you to check
first.
The tsconfig essentials: strict set to true, target, module, lib, and esModuleInterop. Turn
strict on from day one.
Migrating a real file: rename dot js to dot ts, fix the implicit any and possibly-undefined
errors it surfaces, annotate the boundaries first, and use the ts-check comment as a gateway.
By the end you can read, write, and start migrating TypeScript today. The other 90 percent was
JavaScript you already had in your head. TypeScript just wrote it down and started checking it.
Full written tutorial with every line of code:
https://generalistprogrammer.com/tuto...
Want the deep version, with advanced generics, real-world configs, and exercises that make it
stick? The TypeScript Mastery Pack is 19 dollars:
https://generalistprogrammer.gumroad....
Subscribe if this made TypeScript click, and go rename one file to dot ts.
— Chapters —
0:00 You already know 90% of TypeScript
0:57 Type annotations + inference
2:02 Union & literal types
3:12 Interfaces vs type aliases
4:26 Functions: optional, default, rest, void
5:36 TypeScript Mastery Pack ($19)
6:09 Generics — a type as a parameter
7:28 Narrowing + unknown vs any
8:52 tsconfig essentials (strict)
10:01 Migrating a real .js file
11:27 Recap — the whole 10%
12:22 Do this next + free guide
#coding #typescript #typescripttutorial