Skip to content
codinganthem

TypeScript skill check

Practise the TypeScript type system: unions and narrowing, generics, utility types, and inference, including snippets where you decide what compiles and what the result is. Answers assume TypeScript 5 with strict mode.

15

Questions

14 min

Timer can't pause

Multiple choice

TypeScript 5

Choose a level

Question type

About 40% code reading

Topics

  • Basic types
  • Interfaces and type aliases
  • Unions and narrowing
  • Generics
  • Utility types
  • Classes
  • Modules
  • Type inference

Do

Use scratch paper or a notepad to work things out. Skip a question and come back to it later.

Don't

Run the code or look up answers during the check. Open the check in more than one tab or window.

Easy · Mixed · 15 questions · 14 min

By starting, you agree to the Terms and Privacy Policy.

Start practice

Practice checks each answer as you go, with an explanation. The exam is checked when you submit; 9 of 15 passes and earns a certificate.

Checking your levels…

Certificates come from the certified exam: pass with 9 of 15 while signed in. View a sample certificate.

Sample TypeScript questions with answers

These are never used in a check, so seeing their answers here won't give anything away.

  1. Question 1 · Easy · Basic types

    Which statement accurately describes the difference between 'any' and 'unknown' in TypeScript?
    1. A.Properties and methods can be accessed directly on 'any', but 'unknown' requires type checking or narrowing before performing operations.
    2. B.'any' can only accept primitive values, while 'unknown' can hold objects and primitives.
    3. C.'unknown' allows assignments to any type without a cast, whereas 'any' requires a type assertion.
    4. D.'unknown' disables all type checking just like 'any', but produces a compiler warning.
    Show answer

    A. Properties and methods can be accessed directly on 'any', but 'unknown' requires type checking or narrowing before performing operations.

    'unknown' is the type-safe counterpart of 'any'. Anything is assignable to 'unknown', but TypeScript will not let you perform arbitrary operations on an 'unknown' value without narrowing or asserting its type first.
  2. Question 2 · Easy · Interfaces and type aliases

    What happens when you declare two interfaces with the exact same name within the same scope in TypeScript?
    1. A.The second declaration is ignored and treated as an alias for the first.
    2. B.The compiler throws a duplicate identifier error.
    3. C.The second declaration overwrites the first declaration entirely.
    4. D.The compiler merges both declarations into a single interface definition containing fields from both.
    Show answer

    D. The compiler merges both declarations into a single interface definition containing fields from both.

    TypeScript supports declaration merging for interfaces. Declaring multiple interfaces with the same name in the same scope automatically combines their members into one interface.
  3. Question 3 · Moderate · Classes

    What happens when a constructor parameter is prefixed with an access modifier (such as public or readonly) in a TypeScript class?
    1. A.It treats the parameter as optional in constructor invocations.
    2. B.TypeScript emits an error unless the property is explicitly declared again in the class body.
    3. C.It automatically declares and assigns a property of that name on the class instance.
    4. D.It creates a static property on the class constructor function instead of an instance property.
    Show answer

    C. It automatically declares and assigns a property of that name on the class instance.

    This feature, called 'parameter properties', causes TypeScript to automatically declare the member on the class and assign the constructor argument to it upon instantiation.
  4. Question 4 · Advanced · Modules

    Under --moduleResolution nodenext, what is the compiler requirement when importing a relative local TypeScript file math.ts in an ESM context?
    1. A.The import path must explicitly specify the TypeScript source extension, such as ./math.ts.
    2. B.The import path must use the directory index syntax ./math/index.js exclusively.
    3. C.The import path must use the emitted output file extension, such as ./math.js.
    4. D.The import path must omit any file extension, resolving implicitly to ./math.
    Show answer

    C. The import path must use the emitted output file extension, such as ./math.js.

    Under node16 or nodenext module resolution with ECMAScript output, TypeScript mirrors Node's native ESM resolution algorithm, requiring relative import paths to explicitly declare the extension of the emitted JavaScript file (.js or .mjs), not the .ts source file (unless allowImportingTsExtensions is enabled with --noEmit).

How scoring and certificates work

  • Each check has 15 multiple-choice questions with one correct answer, and one timer for the whole check. A question you leave unanswered scores nothing.
  • Practice is free without an account and shows whether each answer is right as you go, with an explanation.
  • The certified exam is scored when you submit. 60% passes, which is 9 of 15. Easy unlocks Moderate, and Moderate unlocks Advanced.
  • Passing the exam while signed in earns a free certificate, valid for one year, with its own verification page. See a sample certificate.

Free tools for TypeScript: JSON to TypeScript, JavaScript Formatter, JSON Schema Generator