type User = {
firstName: string
}
const foo = (u: User) => null
const someUser = {
firstName: "first",
lastName: "last",
}
foo(someUser) // passes
foo({ // breaks
firstName: "first",
lastName: "last"
})
Why does typescript break when calling the function with explicit args:
Argument of type '{ firstName: string; lastName: string; }' is not assignable to parameter of type 'User'.
Object literal may only specify known properties, and 'lastName' does not exist in type 'User'.(2345)
but not when passing an object?