TSTypeScript · Lesson 2 of 10
Basic Types
TypeScript has all JavaScript's types plus a few extras: tuples, enums, `unknown`, `never`, and `void`. The most important one is the one TypeScript infers for you automatically.
✦ Tip
Prefer `unknown` over `any`. With `any`, TypeScript stops checking entirely. With `unknown`, you must narrow the type before using it — which forces you to handle the case properly. Reserve `any` for genuinely untyped third-party data where you'll add types later.
Prefer `unknown` over `any`. With `any`, TypeScript stops checking entirely. With `unknown`, you must narrow the type before using it — which forces you to handle the case properly. Reserve `any` for genuinely untyped third-party data where you'll add types later.