-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Domain: check: Excess Property CheckingHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π Search Terms
inline assignment array derived base push 'Object literal may only specific known properties'
π Version & Regression Information
- This changed between versions 4.9.5 and 5.0.4
β― Playground Link
π» Code
interface Base {
id: number;
}
interface Derived extends Base {
name: string;
}
const items: Base[] = [];
let item1: Derived;
let item2: Derived;
item1 = { id: 1, name: 'this is ok regardless' };
items.push(item1);
items.push((item2 = { id: 2, name: 'this is NOT ok in 5.0.4, but is ok in 4.9.5' }));π Actual behavior
'Object literal may only specific known properties' error
π Expected behavior
The code should not produce an error
Additional information about the issue
It is possible that this is a change to the order in which types are inferred, but I have been unable to find any details in the documentation/changelog.
Metadata
Metadata
Assignees
Labels
Domain: check: Excess Property CheckingHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases