Complete the code to declare a variable that can have some or all properties of the interface.
interface User {
name: string;
age: number;
}
let user: [1]<User> = { name: "Alice" };The Partial type makes all properties optional, so you can provide some or all.
Complete the code to create a function that accepts a partial User object.
function updateUser(user: User, updates: [1]<User>): User { return { ...user, ...updates }; }
The Partial type allows the updates object to have any subset of User properties.
Fix the error in the function parameter type to accept partial updates.
function modifySettings(settings: [1]<Settings>) {
// modify settings
}The Partial type allows passing an object with some or all properties of Settings.
Fill both blanks to create a partial update function with correct typing.
function updateProfile(profile: User, changes: [1]<[2]>) { return { ...profile, ...changes }; }
The function uses Partial with the User type to allow partial updates.
Fill all three blanks to define a function that merges partial settings into defaults.
function mergeDefaults(defaults: [1], overrides: [2]<[3]>) { return { ...defaults, ...overrides }; }
The function merges defaults of type Settings with overrides which is a Partial<Settings>.