What does the following syntax represent in TypeScript?
TypeScript
let value: unknown = "Hello";
let strValue = value as string;
value is cast to string using a type guard.
value is asserted to be of type string.
value is converted to a string at runtime.
value is conditionally mapped to a string.
What does the following syntax represent in TypeScript?
TypeScript
let value: unknown = "Hello";
let strValue = value as string;
It defines a mapped type.
It defines a conditional type.
It defines a custom type assertion.
It defines a type guard for string.
What is the purpose of conditional types in TypeScript?
To conditionally assign types at runtime.
To allow dynamic type conversions.
To create types based on a condition evaluated at compile time.
To replace union types with intersection types.
What does the following mapped type do?
TypeScript
type ReadonlyProperties<T> = {
readonly [K in keyof T]: T[K];
};
Converts all keys of T to strings.
Makes all properties of T optional.
Makes all properties of T readonly.
Maps all values of T to undefined.
What is a template literal type in TypeScript?
A type that allows using variables in strings.
A type that constructs string literals using embedded expressions.
A runtime feature for combining strings.
A way to define constant string unions.
What does the following template literal type produce?
TypeScript
type Status = "loading" | "success" | "error";
type StatusMessage = `Status: ${Status}`;
A union of string literals prefixed with "Status.
A dynamic string generator.
A type for objects with a Status property.
A function type for status messages.
What is the purpose of recursive types in TypeScript?
To define self-referencing type structures.
To prevent infinite type resolution.
To map all properties to optional.
To iterate over union types.
Which of the following defines a recursive type for a nested object structure?
TypeScript
type NestedObject = {
value: string;
children?: NestedObject[];
};
A type with a string value and optional array of NestedObject children.
A type that prevents nested arrays.
A type that enforces all properties to be strings.
A mapped type for optional properties.
What is the purpose of the Pick<T, K> utility type in TypeScript?
To exclude properties K from type T.
To create a new type with only properties K from T.
To make all properties of T readonly.
To create an intersection type with T and K.
How does the Record<K, V> utility type differ from Partial<T>?
Record<K, V> defines a type with keys of type K and values of type V, while Partial<T> makes all properties of T optional
Record<K, V> excludes properties, while Partial<T> includes properties.
Partial<T> applies to strings only, while Record<K, V> applies to numbers only.
Record<K, V> prevents the use of generic types, while Partial<T> allows them.
There are 10 questions to complete.
Take a part in the ongoing discussion
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4