-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Description
🔎 Search Terms
TS2783: "... is specified more than once, so this usage will be overwritten", "This spread always overwrites this property"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about 5.9.3
⏯ Playground Link
💻 Code
type Thing = {
id: string;
label: string;
};
const things: Thing[] = [];
function find(id: string): undefined | Thing {
return things.find(thing => thing.id === id);
}
declare function fun(thing: Thing): void;
fun({
id: 'foo',
...find('foo') ?? {
label: 'Foo',
},
});🙁 Actual behavior
TS2783 on line 15: 'id' is specified more than once is a false positive.
🙂 Expected behavior
Expect no errors. The return type of find('foo') includes undefined, and the right-hand side of the nullish coalescing operation does not override the 'id' property.
Additional information about the issue
No response
RyanCavanaughCopilot
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript