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

Strict typing for object spread in higher order function. #25142

Closed
ccorcos opened this issue Jun 21, 2018 · 2 comments
Closed

Strict typing for object spread in higher order function. #25142

ccorcos opened this issue Jun 21, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@ccorcos
Copy link

ccorcos commented Jun 21, 2018

TypeScript Version: 2.9.2
Search Terms: strict object literal higher order function object spread
Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

Expected behavior:

type A = { x: number, y: number }

const x: A = { x: 1, y: 2 }

const y: A = {...x, b: 10} // Error ✅

function hoc(fn: (a: A) => A) { }

hoc(a => ({a: 1, y: 2, b: 10})) // Error ✅

hoc(a => ({ ...a, b: 10 })) // No Error ❌

Actual behavior:

I would expect the hoc(a => ({ ...a, b: 10 })) to throw an error.

Playground Link: playground

@mhegazy
Copy link
Contributor

mhegazy commented Jun 21, 2018

Duplicate of #12632

@mhegazy mhegazy marked this as a duplicate of #12632 Jun 21, 2018
@mhegazy mhegazy added the Duplicate An existing issue was already created label Jun 21, 2018
@ccorcos
Copy link
Author

ccorcos commented Jun 22, 2018

Thanks!

@ccorcos ccorcos closed this as completed Jun 22, 2018
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
Projects
None yet
Development

No branches or pull requests

2 participants