Address with street, city, and postalCode as string properties.Contact with name as string and address as an Address type.myContact of type Contact with specific values.myContact's address.Address with street, city, and postalCode as string properties.Contact with name as string and address as an Address type.myContact of type Contact with specific values.myContact's address.Address with string properties street, city, and postalCode.Use the type keyword to create a new type with the specified properties.
Contact with a string property name and an address property of type Address.Use the type keyword and refer to the Address type inside Contact.
myContact of type Contact with name set to "Alice", street set to "123 Maple St", city set to "Wonderland", and postalCode set to "W1234".Use an object literal matching the Contact type with nested address object.
console.log statement to print the city property from myContact.address.Use console.log(myContact.address.city) to print the city.
What does a nested object type in TypeScript represent?
For example, { user: { name: string; age: number } }
{ user: { name: string; age: number } } shows a property user which is an object with its own properties.Which of the following is the correct syntax to define a nested object type in TypeScript?
type Profile = {
user: {
id: number;
name: string;
}
};user property with id and name.What will be the output of the following TypeScript code?
type Data = {
info: {
count: number;
label: string;
}
};
const data: Data = {
info: { count: 5, label: 'items' }
};
console.log(data.info.label);data has a property info which is an object with count and label.data.info.label, which is the string "items".Identify the error in this TypeScript nested object type definition:
type Config = {
settings: {
theme: string;
notifications: boolean
}
};
const config: Config = {
settings: {
theme: 'dark',
notifications: 'yes'
}
};notifications: boolean, so it must be true or false.Given this nested object type, how can you define a type for a user profile that includes an address object with street and city?
type UserProfile = {
id: number;
name: string;
address: {
street: string;
city: string;
}
};Which of the following correctly creates a variable profile of type UserProfile?
id, name, and an address object with street and city as strings.address property.Pass the test and this pattern moves unknown