TypeScript Basics

Check your understanding of TypeScript types,interfaces,and basic configurations.

1. What is the primary purpose of TypeScript?
2. Which of the following is a valid type annotation for a variable that holds a string?
3. What is the output of the TypeScript compiler (tsc) when compiling a .ts file?
4. Which TypeScript type allows a variable to hold any value and disables type checking for that variable?
5. How do you declare a function in TypeScript that takes a number parameter and returns a number?
6. What is the 'unknown' type in TypeScript primarily used for?
7. Which keyword is used to define a class in TypeScript?
8. What does the 'as' keyword do in TypeScript?
9. Which of the following are primitive types in TypeScript?
10. Which of the following are valid TypeScript types?
11. Which statements about TypeScript interfaces are true?
12. Which of the following are valid ways to specify an optional property in a TypeScript interface?
13. Which features are introduced by TypeScript compared to vanilla JavaScript?
14. TypeScript is a superset of JavaScript, meaning all valid JavaScript code is also valid TypeScript code.
15. Using the 'any' type is recommended for most TypeScript projects to maximize flexibility.
16. Enums in TypeScript are compiled into objects in JavaScript.
17. TypeScript can infer the type of a variable if it is initialized when declared, eliminating the need for explicit type annotations in such cases.
18. What keyword is used to declare a type alias in TypeScript?
19. What is the standard file extension for TypeScript source files?
20. Name the command-line tool used to compile TypeScript code into JavaScript.
Answered 0 of 0 — 0 correct