

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Learn TypeScript
incomplete
2: Basic Types
incomplete
3: Type Inference
incomplete
4: Why TypeScript
incomplete
5: What Is TypeScript
incomplete
6: Any
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Okay, so we know TypeScript's purpose is to add static types to JavaScript, and we know all JavaScript is valid TypeScript.
In practical terms, what that means is when you compile plain JavaScript code using tsc, your codebase is full of any types.
The any type is exactly what it sounds like - a type that can be anything. The purpose of types, really, is to narrow down the possible values that a variable can hold. From that perspective, any is the most useless type because it doesn't narrow anything down at all! But it's important because it allows you to opt out of type-checking for a variable.
The any type is super useful when you migrate an existing JavaScript codebase to TypeScript. The (very simplified) process is:
.js to .tstsc running without errors (often works out of the box, due to any)any's with more specific typesBoot.dev's front-end used to be JavaScript! We went through this exact process a couple of years ago getting it all converted to TypeScript and slowly purging the any's.
While vibe migrating a JavaScript file to TypeScript, a bunch of any's were inserted into the codebase.
Update the constants from any to their proper types (by using inference).