-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Milestone
Description
Bug Report
π Search Terms
- PropertyDescriptorMap
- PropertyDescriptor
- Spread
π Version & Regression Information
- This has changed since version 4.6
β― Playground Link
Playground link with relevant code:
π» Code
declare const properties1: { [x: string]: PropertyDescriptor };
// This will pass. This is because the type '{ [x: string]: PropertyDescriptor }' can be assigned to the type 'PropertyDescriptorMap'.
Object.defineProperties({}, properties1);
// But when it passes the spread syntax, it fails even though the types are the same.
const { ...properties2 } = properties1;
Object.defineProperties({}, properties2);
π Actual behavior
I get the following error:
Argument of type '{ [x: string]: PropertyDescriptor; }' is not assignable to parameter of type 'PropertyDescriptorMap & ThisType<any>'.
Type '{ [x: string]: PropertyDescriptor; }' is not assignable to type 'PropertyDescriptorMap'.
Index signature for type 'symbol' is missing in type '{ [x: string]: PropertyDescriptor; }'.
But, type { [x: string]: PropertyDescriptor; }
is assignable to type PropertyDescriptorMap
. Objects copied with spread syntax cannot be assigned even though they have the same type.
π Expected behavior
This type error does not occur. For the same type, it should be consistently assignable / non-assignable anywhere.
Josh-Cenawhzx5byb