Skip to content

spreading class results in type with prototype key, which is not present in runtime object #41842

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

Closed
Enteleform opened this issue Dec 6, 2020 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Enteleform
Copy link

TypeScript Version: 4.1.2

Search Terms:
spread class static property prototype

Code

class Foo{
  static bar = 123
  baz = 456
}

const FooProps = {...Foo}
// typeof FooProps === {
//   prototype: Foo
//   bar: number
// }

console.log(FooProps)
// { bar: 123 }

console.log(FooProps.prototype)
// undefined

Expected behavior:

typeof FooProps === {
  bar: number
}

Actual behavior:

typeof FooProps === {
  prototype: Foo
  bar: number
}

Playground Link:
https://www.typescriptlang.org/play?#code/MYGwhgzhAEBiD28DeAoa0IBcyYJbGgCMwAnaAXmgEYAmAZjSLAC8LoAWAVgDYUBfFCmDwAdljiIACiXgAHGJSQA6FQngCA9BuiYAnrICm8AGYT40uQvKKUW9NFkzM8PYYBcZ29vTESHkQCuALaEBiRe0AJCohDwIAZKIPAA5gAUahbyAJQRSEx+1PSRgsJicQlJaRky8kqOLi76Bjl2ASIAJgbGuCIG7ShAA

@RyanCavanaugh
Copy link
Member

Duplicate #9726

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Dec 7, 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
Projects
None yet
Development

No branches or pull requests

3 participants