TypeScript: Type Errors with Object Spread in Function Parameters When Using Partial<T>
I've looked through the documentation and I'm still confused about I'm working with a frustrating scenario with TypeScript when trying to use the object spread syntax in function parameters combined with `Partial<T>`. I have a function that accepts an object of type `Person`, which has required fields like `name` and `age`, but I'm trying to allow partial updates using `Partial<Person>`. Here's a simplified version of my code: ```typescript interface Person { name: string; age: number; } function updatePerson(person: Person, updates: Partial<Person>): Person { return { ...person, ...updates }; } const john: Person = { name: 'John Doe', age: 30 }; const updatedJohn = updatePerson(john, { age: 31 }); console.log(updatedJohn); ``` This works perfectly fine. However, when I try to enforce that the `updates` object should not have any additional properties beyond those defined in `Partial<Person>`, I face some issues. I attempted to extend the object with extra properties, like this: ```typescript const updatedJohn = updatePerson(john, { age: 31, height: 180 }); ``` This should trigger a type behavior, but TypeScript is not complaining, which seems incorrect. I’ve checked my `tsconfig.json` settings, and I have `strict: true` enabled. The relevant part of my configuration looks like this: ```json { "compilerOptions": { "target": "ES6", "module": "commonjs", "strict": true, "noImplicitAny": true } } ``` I expected TypeScript to raise an behavior when trying to add `height`, as it is not a valid property of `Partial<Person>`. Instead, it allows the code to compile without any errors, which is confusing. Is there something I'm missing in the way TypeScript handles object spreads, or perhaps in the way I've defined my types? Any insights would be greatly appreciated!