TypeScript: Typed JavaScript Fundamentals

20 QuestionsIntermediatePublished:

TypeScript: Typed JavaScript Fundamentals

Up to 20 questions, shuffled on every run

Quiz Configuration
Enterto start

Welcome to the TypeScript Basics Quiz! This quiz covers fundamental TypeScript concepts, static typing, and type-safe programming best practices. Each question is multiple-choice, and you’ll find hints to help you along the way. Good luck!

Answer key and explanations20 questions

The quiz above draws 20 questions at random from these 30, so a second attempt will not be the same run. Everything in the pool is listed here.

  1. What is the primary purpose of TypeScript?

    AnswerTo provide static type checking for JavaScript code

  2. Which command is used to compile a TypeScript file into JavaScript?

    Answer`tsc`

  3. How do you define an interface for a User object?

    Answer`interface User { name: string; }`

  4. What does the "any" type do?

    AnswerIt disables type checking for a particular variable

  5. What is a "Tuple" in TypeScript?

    AnswerAn array with a fixed number of elements and known types

  6. Which keyword is used to make an interface property optional?

    Answer`?`

  7. What is an "Enum"?

    AnswerA collection of related and named constant numeric values

  8. What does the "void" type signify when used on a function?

    AnswerThe function performs an action but returns no value

  9. How do you define a Union Type in TypeScript?

    Answer`string | number`

  10. What is the "unknown" type?

    AnswerA safer type that requires a type check before any usage

  11. What is the purpose of the "readonly" keyword?

    AnswerTo prevent a property from being changed after assignment

  12. What is "Generics" in TypeScript?

    AnswerA way to create components that work with a variety of types

  13. Which file contains the configuration for a TypeScript project?

    Answer`tsconfig.json`

  14. What is "Type Inference"?

    AnswerWhen the compiler automatically detects a variable type

  15. What is the "never" type used for?

    AnswerFor functions that do not reach an end point or return

  16. How do you extend an interface?

    Answer`interface Admin extends User`

  17. What is an "Abstract Class"?

    AnswerA base class that cannot be instantiated directly

  18. Which keyword is used to access the parent class constructor?

    Answer`super()`

  19. What is a "Type Guard"?

    AnswerA check that narrows a type within a specific scope

  20. What is the "as" keyword used for?

    Answer`To tell the compiler to treat a value as a specific type`

  21. What is the result of transpiling TypeScript to JavaScript?

    AnswerA standard JavaScript file with all types removed

  22. How do you declare a private property in a TypeScript class?

    Answer`private name: string;`

  23. What is "Literal Types"?

    AnswerA type that can only hold a specific, exact value

  24. What is "Intersection Type"?

    AnswerA type that combines multiple types into a single one

  25. What is the "protected" modifier?

    AnswerIt makes properties visible to a class and its children

  26. How do you define a function type in an interface?

    Answer`myFunc(): void;`

  27. What is "Namespace" in TypeScript?

    AnswerA way to group related code and prevent collisions

  28. What is the "keyof" operator?

    AnswerIt creates a union type of all keys from an object type

  29. What does "Strict Mode" in tsconfig do?

    AnswerIt enables comprehensive checks for more robust code

  30. What is the "!" operator (Non-null assertion)?

    AnswerIt asserts that a value is not null or undefined

Was this useful?

You might also enjoy

Check out some of our other posts on similar topics

JavaScript: Language Fundamentals & Modern Features

JavaScript: Language Fundamentals & Modern Features

Welcome to the JavaScript Basics Quiz! This quiz is designed to test your understanding of fundamental JavaScript concepts, syntax, and modern programming best practices. Each question is multiple-cho

CSS Fundamentals: Selectors, Box Model & Styling

CSS Fundamentals: Selectors, Box Model & Styling

Welcome to the CSS Fundamentals quiz! This quiz will test your knowledge of CSS basics, including selectors, the box model, properties, and layout techniques. Each question is designed to reinforce ke

HTML Semantics & Web Accessibility

HTML Semantics & Web Accessibility

Welcome to the HTML Semantics & Accessibility Quiz! This quiz will test your knowledge of semantic HTML elements and web accessibility best practices. Each question has a hint to help you out, and you

TypeScript Advanced: Types, Generics, Utility Types

TypeScript Advanced: Types, Generics, Utility Types

Welcome to the TypeScript Advanced Quiz! Test your knowledge on advanced types, generics, utility types, and more. Each question has a hint and explanations for all options. Good luck!

Python: Programming Fundamentals & Best Practices

Python: Programming Fundamentals & Best Practices

Welcome to the Python Basics Quiz! This quiz is designed to test your understanding of fundamental Python concepts, syntax, and programming best practices. Each question is multiple-choice, and you'll

Java: Core Language & JVM Fundamentals

Java: Core Language & JVM Fundamentals

Java has quietly powered banks, Android, and countless backend systems for decades, and the language keeps evolving with records, sealed classes, and virtual threads. This quiz walks through the core

6 related posts