QuizzesWhy TypeScript, and How It Runs — Concept Check
intermediate
javascript

Why TypeScript, and How It Runs — Concept Check

Questions on Why TypeScript, and How It Runs. TypeScript is a checker, not a runtime. It erases to JavaScript and disappears — which explains both what it catches and everything it cannot.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Why TypeScript, and How It Runs — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You receive a runtime error when trying to access a property of an API response. The TypeScript code compiles without errors. What is a likely cause?

    • ATypeScript enforces type checks at runtime.
    • BThe API response type was not validated at runtime.
    • CThe API response was correctly typed.
    • DThe TypeScript compiler has a bug.
  2. 2.A developer uses `instanceof` to check if a variable is of a certain interface type in TypeScript. What will happen?

    • AIt will always return false since interfaces are not runtime entities.
    • BIt will correctly check the type at runtime.
    • CIt will always return true if the variable matches the interface.
    • DIt will cause a runtime error because interfaces are not present at runtime.
  3. 3.A team sets `strictNullChecks` to false in their `tsconfig.json`. What is a potential consequence?

    • AThe compiler will treat `null` and `undefined` as separate types.
    • BThe compiler will enforce strict type checks on all variables.
    • CThe compiler will not warn about possible null dereferences.
    • DThe code will not compile without explicit null checks.
  4. 4.You notice a TypeScript project using `noEmit` in its configuration. What is the purpose of this setting?

    • ATo ensure TypeScript compiles faster by skipping type checks.
    • BTo enable TypeScript to enforce runtime type checks.
    • CTo prevent TypeScript from generating JavaScript files.
    • DTo allow TypeScript to run without a Node.js environment.
  5. 5.A developer claims that using TypeScript generics increases runtime performance overhead. What is the truth?

    • AGenerics have no runtime cost because they are erased during compilation.
    • BGenerics require additional memory allocation at runtime.
    • CGenerics are checked at runtime, causing overhead.
    • DGenerics increase runtime performance overhead significantly.
  6. 6.Why might `user.age + 1` cause a compile-time error in TypeScript?

    • ATypeScript does not allow arithmetic operations.
    • BThe TypeScript compiler has a bug.
    • C`user.age` is not a number type.
    • DThe `+` operator is not supported in TypeScript.
  7. 7.A developer uses `JSON.parse(text) as User` in TypeScript. What is a potential issue with this approach?

    • AIt validates the JSON structure at runtime.
    • BIt skips runtime validation, risking runtime errors.
    • CIt enforces compile-time type checks on JSON.
    • DIt ensures the JSON matches the User interface.
  8. 8.What is the effect of setting `noUncheckedIndexedAccess` to true in TypeScript?

    • AIt ensures arrays can only contain numbers.
    • BIt enforces checks for undefined when accessing array elements.
    • CIt allows accessing array elements without checks.
    • DIt disables all type checks for array elements.