TypeScript MCQ Test: TypeScript MCQs - Practice Questions
1. How do you define an optional property in a TypeScript interface?
2. What is TypeScript's 'module' system used for?
3. Which utility type transforms all properties of a type to be read-only?
4. In TypeScript, how do you define a tuple?
5. What is TypeScript's 'generics' feature used for?
6. In TypeScript, how do you define an optional function parameter?
7. What is the TypeScript feature used to combine multiple types into a single type?
8. What is the use of the 'this' parameter in TypeScript functions?
9. What is the TypeScript equivalent of JavaScript's 'for...in' loop?
10. In TypeScript, what is the purpose of the 'try/catch' statement?
11. Which of the following is the correct way to define an interface for a function in TypeScript?
12. In TypeScript, what is the purpose of the 'namespace' keyword?
13. What is TypeScript's 'arrow function' syntax used for?
14. What is the primary goal of TypeScript?
15. What is TypeScript's 'class' used for?
16. How do you declare a readonly array in TypeScript?
17. What is TypeScript's 'namespace' used for?
18. What is TypeScript's 'export' keyword used for?
19. Which TypeScript feature is used to create a new type that is composed of existing types?
20. Which keyword is used to declare a variable in TypeScript with a specific type?
21. What TypeScript feature allows for specifying an exact set of string values for a type?
22. What is the purpose of the 'unknown' type in TypeScript?
23. What is the TypeScript equivalent of 'console.log()' in JavaScript?
24. Which keyword is used to declare a variable in TypeScript?
25. Which TypeScript feature is used to make a property or method in a class inaccessible from outside the class?
26. Which TypeScript feature allows you to work with a variable that could be of several different types?
27. What is the purpose of TypeScript's 'import' statement?
28. In TypeScript, which of the following is the correct way to define an array of numbers?
29. What is TypeScript's 'tuple' data type used for?
30. What is the purpose of the 'break' statement in TypeScript?
31. Which programming language is TypeScript based on?
32. What is TypeScript's 'type inference'?
33. Which keyword is used to declare a constant variable in TypeScript?
34. What is the purpose of the 'interface' keyword in TypeScript?
35. Which TypeScript keyword is used to indicate that a function doesn't return any value?
36. Which TypeScript feature is used for ensuring code blocks are never reached?
37. What is TypeScript?
38. What is the TypeScript equivalent of JavaScript's 'constructor' function?
39. Which of the following correctly describes the 'Partial' utility type in TypeScript?
40. What is the use of the 'declare' keyword in TypeScript?
41. Which of the following is a valid way to define a string variable in TypeScript?
42. Which utility type constructs a type by picking the set of properties 'K' from 'T'?
43. What is the purpose of TypeScript's 'null' and 'undefined' types?
44. Which operator is used to specify a type guard in TypeScript?
45. In TypeScript, how do you define a function?
46. In TypeScript, how do you declare a variable with a specific type?
47. What is a discriminated union in TypeScript?
48. How do you define a class in TypeScript?
49. How can you create a custom type guard in TypeScript?
50. What is the purpose of TypeScript's 'enum'?