Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No excess properties error on function return type #37017

Closed
mgiedrius opened this issue Feb 25, 2020 · 2 comments
Closed

No excess properties error on function return type #37017

mgiedrius opened this issue Feb 25, 2020 · 2 comments
Labels
Duplicate An existing issue was already created Fix Available A PR has been opened for this issue

Comments

@mgiedrius
Copy link

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

@IllusionMH
Copy link
Contributor

IllusionMH commented Feb 25, 2020

Duplicate of #12632 which requires #241

(Sorry if couple of comments were posted - GH had issues with API)

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Feb 25, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants