Complete the code to define a type alias for a user object.
type User = [1];The correct syntax to define a type alias for an object with properties is using curly braces with property names and types.
Complete the code to create a function type that takes a string and returns a number.
type StringToNumber = [1];The function type syntax uses parentheses for parameters and an arrow to the return type. Here, input is a string and the return is a number.
Fix the error in the interface to make the property optional.
interface Product {
id: number;
name[1] string;
}Adding a question mark after the property name makes it optional in TypeScript interfaces.
Complete the code to create a mapped type that makes all properties readonly.
type Readonly<T> = {
[1] P in keyof T:: readonly T[P];
};In mapped types, 'in' iterates over keys and ':' assigns the type. 'readonly' is placed before the property name, not in the blanks.
Fill both blanks to define a conditional type that checks if T is a string and returns boolean or number.
type IsString<T> = T [1] string [2] boolean : number;
Conditional types use 'extends' to check, '?' for true case, and ':' for false case.