-
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 created
Description
TypeScript Version: 2.3.2
Code
class Foo<P> {
setProperties(props: P) {
const newProps = { ...props };
}
}
class Bar<P extends object> {
setProperties(props: P) {
const newProps = { ...props };
}
}
class Baz<P extends { [prop: string]: any; }> {
setProperties(props: P) {
const newProps = { ...props };
}
}
class Qat<P extends object = object> {
setProperties(props: P) {
const newProps = { ...props };
}
}
Expected behavior:
That properties are spread on class Bar
, class Baz
, and class Qat
.
Actual behavior:
All three cases report that Spread types may only be created from object types.
In all cases, the generic could be inferred to be of an object type, so the restriction seems to be arbitrary.
timocov, ezhukovskiy, IOuser, vincekovacs, zheeeng and 2 more
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created