TypeScript MCQ Test: TypeScript MCQs - Practice Questions
1. What is the correct way to annotate a function return type in TypeScript?
2. What is the purpose of the 'extends' keyword in generic constraints in TypeScript?
3. What does the 'keyof' keyword do in TypeScript?
4. Which programming language is TypeScript based on?
5. In TypeScript, what is the purpose of the 'as' keyword?
6. Which of the following is a valid way to define a string variable in TypeScript?
7. What does the 'is' keyword do in a TypeScript type predicate?
8. Which of the following is the correct way to define an interface for a function in TypeScript?
9. What is TypeScript primarily used for?
10. In TypeScript, what is the purpose of the 'try/catch' statement?
11. Which data type is used to represent a collection of values in TypeScript?
12. Which TypeScript feature is used to make a property or method in a class inaccessible from outside the class?
13. What is the purpose of TypeScript's 'as' keyword?
14. Which TypeScript feature is used to apply metadata to classes, methods, or properties?
15. Which TypeScript data type is used for variables that may have a 'null' or 'undefined' value?
16. What is TypeScript's 'type inference'?
17. In TypeScript, what is the purpose of the 'import' statement?
18. In TypeScript, what is the 'any' type used for?
19. Which of the following correctly describes the 'Partial' utility type in TypeScript?
20. How can you create a custom type guard in TypeScript?