storybook
storybook copied to clipboard
Cannot find module 'react-textarea-autosize' or its corresponding type declarations
Describe the bug
While trying to upgrade our typescript project to storybook 6.5.x (specifically, 6.5.9), we're getting the below error when running yarn tsc
, this was not an issue with our previous version, 6.4.0. It looks like @storybook/components
should have a dependency on react-textarea-autosize
instead a devDependency
here since it's used here and available to users of storybook through Form.Textarea
.
node_modules/@storybook/components/dist/ts3.9/index.d.ts(278,72): error TS2307: Cannot find module 'react-textarea-autosize' or its corresponding type declarations. node_modules/@storybook/components/dist/ts3.9/index.d.ts(278,213): error TS2307: Cannot find module 'react-textarea-autosize' or its corresponding type declarations.
To Reproduce
- Update a typescript project storybook to 6.5.9
- run
yarn tsc
/npx tsc
System System: OS: macOS 12.4 CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Binaries: Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.13.1/bin/yarn npm: 6.14.16 - ~/.nvm/versions/node/v14.19.0/bin/npm Browsers: Chrome: 103.0.5060.114 Firefox: 100.0.2 Safari: 15.5 npmPackages: @storybook/addon-a11y: ~6.5.9 => 6.5.9 @storybook/addon-actions: ~6.5.9 => 6.5.9 @storybook/addon-docs: ~6.5.9 => 6.5.9 @storybook/addon-essentials: ~6.5.9 => 6.5.9 @storybook/addon-links: ~6.5.9 => 6.5.9 @storybook/addon-storysource: ~6.5.9 => 6.5.9 @storybook/addons: ~6.5.9 => 6.5.9 @storybook/components: ~6.5.9 => 6.5.9 @storybook/react: ^6.5.9 => 6.5.9 @storybook/source-loader: ~6.5.9 => 6.5.9 @storybook/theming: ~6.5.9 => 6.5.9
Additional context Add any other context about the problem here.
i have just started to get this after upgrading
@drewbrend did you find a workaround?
No, but I don't see this issue anymore, I'm not sure what changed, I can install 6.5.9 and newer versions without issue now. I won't close the issue for now since you're seeing it.
I have the same problem. A workaround is to npm install react-textarea-autosize
.
This issue is fixed in 7.0 beta
This change seems to have been reverted/never made it into the current release, should this be re opened?
What makes you suggest that @jtstothard ? Do you have a reproduction?
I also see this again after going through my dependencies and removing react-textarea-autosize
because we don't use it - now I get the type issue when running tsc
on my project.
This really should be a direct dependency
, not a devDependency
.
I'm in version 7.4.6 and still see this issue
version 7.6.4, the issue persists
Our dist
should not be referencing react-textarea-autosize
at all, it's bundled in.
I'm confused how this could still be an issue.
Does anyone have a reproduction I could see this problem in?
I'm not sure what you mean that it's being bundled in. It's still being imported from here, and it's still a devDependency here
Bundled in, means that the output dist
will contain the package.
That import will be gone in dist
.
So yes, it's a devDependency, because at runtime this reference should not exist anymore.
I can still reproduce this with v7.5.3, I have react-textarea-autosize
installed in my project as a workaround, but when removed I get the issue again.
This is specifically a TS error, storybook seems to run fine. Have you also bundled the types for react-textarea-autosize
?
Does anyone have a reproduction I could see this problem in?
My project is not open source and I don't have time at the moment to create a reproduction repo, unfortunately
OK, I see this in our dist:
So that confirms the issue.. I'm not sure why tsup
isn't bundling the type-definitions in, I'll see if I can investigate.