readyforhires

Intermediate TypeScript test (Intermediate)

30 questions · 35 minutes · Free

Generics, utility types, modules and typing real apps.

Take the Intermediate TypeScript test

What it covers

Interview format

Earn a certificate

The Intermediate TypeScript test is one of the 7 tests of the Frontend Developer: Intermediate learning path. Pass it and the other 6 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.

Sample learning path certificate for Frontend Developer: Intermediate, made out to “Your name” and marked SAMPLE
Pass with 70% or more to earn a verifiable certificate. This is a sample: yours carries your name, the date you earned it and its own verify code.

Sample questions

5 sample questions from the Intermediate TypeScript test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. How are error objects typically typed in Node.js when handling system errors (e.g., from fs or net modules)?

    1. The error object is typed as NodeJS.Exception
    2. The error object is typed as NodeJS.ErrnoException
    3. The error object is not typed explicitly
    4. The error object is typed as Error

    Answer: B. The error object is typed as NodeJS.ErrnoException

    In Node.js, when working with system errors (such as those from fs or net modules), the error object is typically typed as NodeJS.ErrnoException. This type extends the standard Error type and includes additional properties like code and errno. The other options do not accurately represent the typing used for Node.js error objects.

  2. Which of the following best describes the difference between mapped types with keyof and the Record utility type in TypeScript?

    1. Mapped types with keyof are used to create a type with a specific set of keys and a common value type, while Record is used to create a new type based on the properties of an existing type.
    2. Mapped types with keyof are used to transform or derive new types based on the properties of an existing type, while Record is used to create a type with a specific set of keys and a common value type.
    3. Mapped types with keyof are used to create a type with a specific set of keys and a common value type, while Record is used to transform or derive new types based on the properties of an existing type.
    4. Mapped types with keyof are used to create new types based on the properties of an existing type, while Record is used to create a type with a specific set of keys and a common value type.

    Answer: D. Mapped types with keyof are used to create new types based on the properties of an existing type, while Record is used to create a type with a specific set of keys and a common value type.

    Mapped types with keyof are used to transform or derive new types based on the properties of an existing type, which is useful for scenarios like creating read-only versions of types or modifying property types. On the other hand, Record is a utility type that creates a type with a specific set of keys and a common value type, which is useful for creating objects with a fixed set of keys and values. The distinction between the two is important in scenarios where you need to either modify existing types or create entirely new types with predefined keys and values.

  3. Which TypeScript type utility is used to extract the parameters of a function type into a tuple type?

    1. Parameters type utility
    2. ReturnType type utility
    3. ConstructorParameters type utility
    4. Required type utility

    Answer: A. Parameters type utility

    The Parameters type utility is used to extract the parameters of a function type into a tuple type. It is especially useful when you need to work with the arguments of a function in a type-safe manner. The other options refer to other type utilities, but none of them are used for extracting function parameters.

  4. Which of the following TypeScript expressions correctly creates a type where the 'name' property is readonly?

    1. Partial<{ name: string }>
    2. Pick<{ name: string }, 'name'>
    3. Readonly<{ name: string }>
    4. Omit<{ name: string }, 'name'>

    Answer: C. Readonly<{ name: string }>

    The Readonly type utility makes all properties of an object readonly, preventing them from being modified. In this case, { name: string } becomes Readonly<{ name: string }>, which ensures that the name property cannot be reassigned.

  5. Which TypeScript utility type is used to construct a new type by selecting a subset of properties from an existing type?

    1. Pick type utility
    2. Exclude type utility
    3. Omit type utility
    4. Extract type utility

    Answer: A. Pick type utility

    The Pick type utility is used to construct a type by picking a set of properties from another type. It is a commonly used utility in TypeScript for creating new types based on existing ones. The other options are not valid type utilities in TypeScript.

Frequently asked questions

How many questions are in the Intermediate TypeScript test?
30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
What does the Intermediate TypeScript test cover?
Generics and constraints, Utility types, Discriminated unions, Modules and declaration files, Typing React and Node.
Is the Intermediate TypeScript test free?
Yes. It is free to take with a readyforhires account.
What level is the Intermediate TypeScript test?
Intermediate, in Frontend.

More Frontend tests

Roles that test these skills

Companies that test these skills

All practice tests · All Frontend tests

Last updated