What is a Type Alias in TypeScript?
A function that defines a new type
A way to create a new name for an existing type
A reserved keyword for defining interfaces
A feature used only for primitive types
How do type aliases enhance code readability in TypeScript?
By providing an alias for complex data structures
By making primitive types more readable
By replacing all interfaces with type aliases
By reducing the number of functions in the code
Which of the following is a valid use case for Type Aliases?
Defining a complex object structure
Creating a union of multiple types
Assigning a name to a function signature
What is the main difference between Type Aliases and Interfaces in TypeScript?
Type aliases can define primitive types, whereas interfaces cannot
Interfaces support method merging, whereas type aliases do not
Type aliases are always preferred over interfaces
Interfaces can define union types, whereas type aliases cannot
Which of the following is a correct example of a type alias for a union type?
A variable with a single type
A type that can hold only one value
A type that combines multiple possible types
A type that restricts values to numbers only
Can type aliases be used to define function signatures?
Yes, type aliases can be used to define function signatures
No, only interfaces can define function signatures
Only with arrow functions
What will happen if you try to extend a type alias using extends like an interface?
It will throw a TypeScript error
It will merge with the existing type
It will be ignored by the TypeScript compiler
How can you combine multiple type aliases in TypeScript?
Using the | (pipe) operator for union types
Using the & (ampersand) operator for intersection types
Type aliases cannot be combined
What will be the output of the following code?
TypeScript
type ID = string | number;
let userID: ID = 42;
Why would you use a Type Alias instead of an Interface?
To define primitive types
To define complex object structures with unions
To define function signatures
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