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

Type of withKnobs #5727

Closed
Jack-Barry opened this issue Feb 22, 2019 · 2 comments
Closed

Type of withKnobs #5727

Jack-Barry opened this issue Feb 22, 2019 · 2 comments

Comments

@Jack-Barry
Copy link
Contributor

Describe the bug
The type of withKnobs is not valid for the addDecorator function. Looks like the @types/storybook_addon-knobs is out of date maybe?

To Reproduce

Using the following relevant libraries:

    "@babel/core": "^7.2.2",
    "@storybook/addon-knobs": "^4.1.13",
    "@storybook/vue": "^4.1.11",
    "@types/node": "^11.9.4",
    "@types/react": "^16.8.4",
    "@types/storybook__addon-knobs": "^4.0.1",
    "@types/storybook__vue": "^3.3.2",
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.5",
    "babel-preset-vue": "^2.0.2",
    "ts-loader": "^5.3.3",
    "typescript": "^3.3.3",
    "vue-template-compiler": "^2.6.6",
    "vue": "^2.6.6"

Not exactly sure the @types/react is needed, but it's part of the docs for using knobs with TypeScript.

Component.stories.ts

import { storiesOf, Story } from '@storybook/vue'
import { withKnobs, text } from '@storybook/addon-knobs'
import MyComponent from './MyComponent.vue'

const stories: Story = storiesOf('MyComponent.vue', module)

// This throws a type checking error
stories.addDecorator(withKnobs)

// This compiles and works as expected
stories.addDecorator(<any>withKnobs)

stories.add('as component', () => ({
  components: { MyComponent },
  props: {
    text: {
      default: text('Text', 'some text')
    }
  },
  template: '<my-component></my-component>'
})

System:

  • OS: Windows10
  • Device: Toshiba Satellite
  • Browser: N/A
  • Framework: Vue
  • Addons: knobs
  • Knobs Version: 4.1.13
  • Knobs Types Version: 4.0.1 (This is latest)
  • Storybook Version: 4.1.11

Additional context

This isn't a huge deal, just a minor annoyance as I cringe any time I have to use the any type.

@shilman
Copy link
Member

shilman commented Feb 23, 2019

Thanks for the bug! Unfortunately, we don't maintain the types on DefinitelyTyped and I'm not sure about what's the procedure for getting those updated.

The good news is that we're in the process of converting our codebase into Typescript, so you should be seeing those types defined "in house" in an upcoming release. You can check the progress and contribute yourself here: #5030

Closing this for now! 🙇

@shilman shilman closed this as completed Feb 23, 2019
@Jack-Barry
Copy link
Contributor Author

Awesome, that will be great! Thanks @shilman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants