Skip to content
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

Default value being shown as a function, when really it's a function that returns an object #122

Closed
philwolstenholme opened this issue Apr 20, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@philwolstenholme
Copy link
Contributor

philwolstenholme commented Apr 20, 2018

This is my Vue prop:

    thresholds: {
      type: Object,
      default: () => ({
        orange: 50,
        green: 80,
      }),
    },

But the styleguide is displaying my default value as 'Function'

@rafaesc
Copy link
Member

rafaesc commented Apr 23, 2018

Hi @philwolstenholme,

I don't sure if this an issue, because it shows

image

and it say that it accept a type of object.

PD: Thanks for the donation :D

@philwolstenholme
Copy link
Contributor Author

No problem about the coffee/beer donation! :)

You're right about the function showing in the tooltip, I had spotted that, but I thought it might be clearer if the value returned by the function was shown instead.

We have to use functions for arrays and object default values in Vue components (vuejs/vue#1032 (comment)) but to the end user the useful information is the default value returned by the function, not the function itself.

I don't think this is a bug though, probably more of a feature request :)

@elevatebart elevatebart added the enhancement New feature or request label Jan 21, 2019
@elevatebart
Copy link
Member

We could try using buble to compile it then try executing it in isolation and if it succeeds return the value.

try{
  src = buble.compile(defaultValueString)
  defaultValueString = new Function(src)()
}catch(){}

@rafaesc what do you think?

@elevatebart elevatebart self-assigned this Jan 21, 2019
@elevatebart
Copy link
Member

This one I fixed ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants