Describe the bug
In Storybook, any story arguments that are or contain Maps, Sets, and possibly instances of other classes, have a spurious _constructor-name_ property added to them.
This can interfere with code that's dealing with properties of object generically.
Steps to reproduce the behavior
- Make a component that displays
Object.getOwnPropertyKeys() of an argument
- Use the component in a story with a Map as the argument
- See
_constructor-name_ show up even though neither the story code nor the component added it.
The culprit appears to be here:
|
Object.assign(converted, { '_constructor-name_': value.constructor.name }); |
Expected behavior
Serialized objects are not mutated. Deserialized objects don't have extra properties.
A serialization library should not be modifying the objects sent tone serialized. If these are deserialized objects, then special JSON properties should be excluded from the serialization.
Screenshots and/or logs
Here's a screen shot of an object-inspector widget I'm building that's showing these extra properties inside Storybook:
Environment
Not an environment-specific issue.
Additional context
This bug has been reported multiple times on Storybook:
Describe the bug
In Storybook, any story arguments that are or contain Maps, Sets, and possibly instances of other classes, have a spurious
_constructor-name_property added to them.This can interfere with code that's dealing with properties of object generically.
Steps to reproduce the behavior
Object.getOwnPropertyKeys()of an argument_constructor-name_show up even though neither the story code nor the component added it.The culprit appears to be here:
telejson/src/index.ts
Line 298 in d4d6cd0
Expected behavior
Serialized objects are not mutated. Deserialized objects don't have extra properties.
A serialization library should not be modifying the objects sent tone serialized. If these are deserialized objects, then special JSON properties should be excluded from the serialization.
Screenshots and/or logs
Here's a screen shot of an object-inspector widget I'm building that's showing these extra properties inside Storybook:
Environment
Not an environment-specific issue.
Additional context
This bug has been reported multiple times on Storybook: