Suggestion: perform excess property checks when spreading an inline object literal
<!-- π¨ STOP π¨ STOP π¨ STOP π¨ Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section! Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ Please fill in the *entire* template below. --> <!-- Please try to reproduce the issue with the latest published version. It may have already been fixed. For npm: `typescript@next` This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly --> **TypeScript Version:** 3.9.2 <!-- Search terms you tried before logging this (so others can find this issue more easily) --> **Search Terms:** **Code** ```ts declare const someCondition: boolean; type MyObject = { foo: number; bar?: number }; const a: MyObject = { foo: 1, bar: 2, // β Error because `invalid` is an excess property invalid: 3, }; const b: MyObject = { foo: 1, ...(someCondition ? { bar: 2, // β `invalid` is an excess property, but we don't get an error here invalid: 3, } : {}), }; ``` In the example above, I only want to include specific properties when a condition is met. That's the only reason I'm using spread here. I understand that TypeScript only performs
Posted by OliverJAsh on Aug 11, 2020, 3:18 PM
Tags
Related issues
- [Meta] Feedback on granular control over Copilot changes
- unexpected status 401 Unauthorized issue
- [MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
- [CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
- Video stops playing after some minutes
- [MODEL] Claude verbose code comments by default β ignores instructions to stop.
Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments
github (Software)
[Meta] Feedback on granular control over Copilot changes
unexpected status 401 Unauthorized issue
[MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
[CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
Video stops playing after some minutes
[MODEL] Claude verbose code comments by default β ignores instructions to stop.
Scope Codex VS Code chats to the current workspace/project
Update on "Co-authored-by: Copilot" in commit messages
Suggestion: perform excess property checks when spreading an inline object literal
<!-- π¨ STOP π¨ STOP π¨ STOP π¨ Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section! Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ Please fill in the *entire* template below. --> <!-- Please try to reproduce the issue with the latest published version. It may have already been fixed. For npm: `typescript@next` This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly --> **TypeScript Version:** 3.9.2 <!-- Search terms you tried before logging this (so others can find this issue more easily) --> **Search Terms:** **Code** ```ts declare const someCondition: boolean; type MyObject = { foo: number; bar?: number }; const a: MyObject = { foo: 1, bar: 2, // β Error because `invalid` is an excess property invalid: 3, }; const b: MyObject = { foo: 1, ...(someCondition ? { bar: 2, // β `invalid` is an excess property, but we don't get an error here invalid: 3, } : {}), }; ``` In the example above, I only want to include specific properties when a condition is met. That's the only reason I'm using spread here. I understand that TypeScript only performs
Comments (0)
No comments yet. Start the discussion.