TypeScript adds types to JavaScript, catching errors at compile time instead of runtime.
TypeScript
Add type safety to your JavaScript code.
Hello TypeScript
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Create a typed message variable and print it
Click "Run" to execute your code...When does TypeScript catch type errors?
SUMMARY
In this section, you learned how to add type annotations to JavaScript. Next, you'll learn about basic types in TypeScript.
Basic Types
TypeScript has several basic types for primitive values.
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Declare typed variables: name (string), age (number), isStudent (boolean)
Click "Run" to execute your code...What symbol is used to add a type annotation in TypeScript?
SUMMARY
In this section, you learned about basic types in TypeScript. Next, you'll learn how TypeScript infers types automatically.
Arithmetic Operations
TypeScript uses the same arithmetic operators as JavaScript, but with type safety to catch errors.
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Calculate area and print "Area: {area}"
Click "Run" to execute your code...What type does TypeScript infer for let x = 10 + 5?
SUMMARY
In this section, you learned how TypeScript infers types automatically. Next, you'll learn how to perform arithmetic operations.
Unlock 10 More Lessons
You've completed the free preview! Upgrade to Pro to access all 12 lessons in this course, plus advanced projects and certificates.
- String Operations
- Conditionals
- For Loops
- While Loops
- Functions
- Arrays
- Objects and Interfaces
- Advanced Types
- Final Project: Typed Task Manager