Storybook: [Typescript/add-knobs] error TS7016: Could not find a declaration file for module '@storybook/addon-knobs/react'.

Created on 9 Apr 2018  路  6Comments  路  Source: storybookjs/storybook

Bug or support request summary

I'm new to typescript and to storybook and having a problem to make knob work with typescript.
Maybe I am missing something, but I get a TS7016 error on the import:

import { withKnobs } from '@storybook/addon-knobs/react';

I've added

"@types/storybook__addon-knobs": "^3.2.3",
"@types/storybook__react": "^3.0.7",

Any pointers appreciated :)

Steps to reproduce

I've setup a basic repo to reproduce my problem.
Basically it is a create-react-app (with typescript scripts) + getStorybook + typescript config for storybook.

https://github.com/nihaux/typescript-storybook-knob

yarn install
yarn run storybook

should get you

ERROR in ./src/stories/index.stories.tsx
(3,27): error TS7016: Could not find a declaration file for module '@storybook/addon-knobs/react'. '[...]/typescript-storybook-knob/node_modules/@storybook/addon-knobs/react.js' implicitly has an 'any' type.

Please specify which version of Storybook and optionally any affected addons that you're running

"@storybook/react": "^3.4.0",
"@storybook/addon-knobs": "^3.4.0",
"@types/storybook__addon-knobs": "^3.2.3",
"@types/storybook__react": "^3.0.7",
"@storybook/addons": "^3.4.0",
"@storybook/react": "^3.4.0",
"@storybook/addon-knobs": "^3.4.0",
knobs inactive typescript

Most helpful comment

Works for me without adding @types/storybook__addon-knobs. Here's how I configured simply my Storybook with TypeScript.

All 6 comments

Maybe related to the #3374

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

For those who also run into this problem:
yarn add @types/node @types/react @types/storybook__addon-knobs --dev

That solved it. Documentation only mentions first two, CLI error only mentions the last. You need all three.

Works for me without adding @types/storybook__addon-knobs. Here's how I configured simply my Storybook with TypeScript.

I have the same error

"@types/storybook__addon-knobs": "^5.2.1",
"@storybook/addon-knobs": "^5.3.14",

Was this page helpful?
0 / 5 - 0 ratings