Complete the code to define a type with a property 'name' of type string.
type Person = { name: [1] };The property 'name' should be of type string to match the expected structure.
Complete the code to assign an object to a variable of type Person.
const user: Person = { name: [1] };The 'name' property must be a string, so 'Alice' is the correct value.
Fix the error by completing the code to check if an object matches the Person type structurally.
function isPerson(obj: any): obj is Person { return typeof obj.name === [1]; }To confirm the object has a 'name' property of type string, check if typeof obj.name === 'string'.
Fill both blanks to create a function that accepts any object with a 'name' property of type string.
function greet([1]: { [2]: string }) { return `Hello, $[1]!`; }
The function destructures the parameter to get the 'name' property, so both blanks should be 'name'.
Fill all three blanks to create a structural type and assign an object matching it.
type [1] = { [2]: number }; const item: [1] = { [2]: 5 };
The type is named 'Item', it has a 'quantity' property of type number, and the object uses the same type and property.