storybook icon indicating copy to clipboard operation
storybook copied to clipboard

Cannot find module 'react-textarea-autosize' or its corresponding type declarations

Open drewbrend opened this issue 2 years ago • 4 comments

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.

drewbrend avatar Jul 18 '22 17:07 drewbrend

i have just started to get this after upgrading

derekreilly1990 avatar Sep 30 '22 05:09 derekreilly1990

@drewbrend did you find a workaround?

derekreilly1990 avatar Sep 30 '22 06:09 derekreilly1990

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.

drewbrend avatar Oct 04 '22 20:10 drewbrend

I have the same problem. A workaround is to npm install react-textarea-autosize.

lukasvice avatar Oct 11 '22 08:10 lukasvice

This issue is fixed in 7.0 beta

ndelangen avatar Feb 13 '23 15:02 ndelangen

This change seems to have been reverted/never made it into the current release, should this be re opened?

jtstothard avatar Jun 14 '23 10:06 jtstothard

What makes you suggest that @jtstothard ? Do you have a reproduction?

ndelangen avatar Jun 14 '23 22:06 ndelangen

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.

drewbrend avatar Jul 19 '23 19:07 drewbrend

I'm in version 7.4.6 and still see this issue

Jintus avatar Oct 12 '23 08:10 Jintus

version 7.6.4, the issue persists

Davidihl avatar Dec 13 '23 10:12 Davidihl

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?

ndelangen avatar Dec 13 '23 11:12 ndelangen

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

drewbrend avatar Dec 13 '23 14:12 drewbrend

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.

ndelangen avatar Dec 14 '23 16:12 ndelangen

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

drewbrend avatar Dec 14 '23 16:12 drewbrend

OK, I see this in our dist: Screenshot 2023-12-15 at 09 20 13

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.

ndelangen avatar Dec 15 '23 08:12 ndelangen