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

Object Literal + spread + public property #23329

Closed
unional opened this issue Apr 11, 2018 · 2 comments
Closed

Object Literal + spread + public property #23329

unional opened this issue Apr 11, 2018 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@unional
Copy link
Contributor

unional commented Apr 11, 2018

Sorry about the title. Can't think of a good way to describe the issue. Feel free to modify it.

Here is the issue:

class Foo {
    do() { }
}
class Boo extends Foo {
    public x: number
}
function foo(f: Foo) { return f }
const boo = new Boo()

// Argument of type '{ x: number; }' is not assignable to parameter of type 'Foo'.
//  Object literal may only specify known properties, and 'x' does not exist in type 'Foo'.
foo({ ...boo })

playground link

unional added a commit to unional/satisfier that referenced this issue Apr 11, 2018
@ghost
Copy link

ghost commented Apr 11, 2018

In addition to the extra property, spreading an object removes methods. So foo({ ... new Foo() }) would also fail.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Apr 11, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants