-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Description
TypeScript Version: Nightly, 3.7.5
Search Terms: excess property, computed property
Code
const a = <T>(shape: T | (() => T)): T => {
return shape instanceof Function ? shape() : shape;
}
//Case 1
a<{ x: string }>(() => ({ x: '', o: '' })); // I expect this to fail
//Case 2
a<{ x: string }>({ x: '', o: '' }); // Fails as expected
Expected behavior:
I expect Case 1
to show error similar to Case 2
because returned object contains more properties than described in generic type.
Actual behavior:
Case 1
is a valid typescript
Playground Link: Playground Link
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdFix AvailableA PR has been opened for this issueA PR has been opened for this issue