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
Cannot use symbol as story argument property #14055
Comments
Args must be serializable to JSON - this is done with https://github.com/storybookjs/telejson, but that only supports symbols as values in args. I'm not sure non-string keys are something we'd want to support, but I'll ask around. |
This will be addressed in #13888 The gist is we'll introduce a kind of "select" control for which keys are used as arg (which gets serialized/deserialized) rather than the value. That way the value can be anything, because it will stay within the scope of the preview and not need to be sent to the manager over the channel (which uses telejson). Closing as duplicate. |
Symbol as key is a pretty "common" thing. By common I mean it's used a lot in TypeScript for advanced types like nominal types aka branding. It also allow some really cool architecture. |
@JesusTheHun it would be great if you could get Symbols to work properly in telejson. Another issue however is serialization to the URL, which only allows |
@ghengeveld I've created a PR in telejson to truly support global symbols but it is simply impossible to have local symbols to be serialized, it's a JS limitation that is also a feature. Now regarding the serialization to the url, I don't know where you need that but it's very likely a bad solution. You could base64'ify the content to pass the data but then you run into browser url size limitation of 2048 chars. |
Describe the bug
I was doing some dark magic to be able to test connected component and I wanted to use a symbol into the template arguments but it turns out they are stripped away :
Use case
Description
As you can read the
const ConnectedStorePropsKey
is currently a string: that's my workaround.Initially I used a symbol (that was exported to be use in the stories) but it turns out it is striped away and the
const component
never carries it,Object.getOwnPropertySymbols(props).length === 0
Is there any particular reason why and is it a desired behavior ?
The text was updated successfully, but these errors were encountered: