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

[Bug] Types definitions are missing in 3.0.5 #116

Closed
EugeneDraitsev opened this issue Aug 1, 2023 · 8 comments
Closed

[Bug] Types definitions are missing in 3.0.5 #116

EugeneDraitsev opened this issue Aug 1, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@EugeneDraitsev
Copy link

EugeneDraitsev commented Aug 1, 2023

Describe the bug

Types definitions are missing in 3.0.5

Steps to reproduce the behavior

  1. Create a story with
<script lang="ts">
  import { Meta, Story, Template } from '@storybook/addon-svelte-csf';
</script>
  1. Run yarn make check or svelte-check or tsc --noEmit
  2. See an error:
Error: Cannot find module '@storybook/addon-svelte-csf' or its corresponding type declarations. (ts)
<script lang="ts">
  import { Meta, Story, Template } from '@storybook/addon-svelte-csf';

Expected behavior

No tsc error

Additional context

It works fine with @storybook/addon-svelte-csf version 3.0.4

Repo by @olafurw: olafurw/addon-svelte-csf-import-bug (originally #117)

@EugeneDraitsev EugeneDraitsev added the bug Something isn't working label Aug 1, 2023
@hobbes7878
Copy link
Collaborator

Should be fixed in #115.

@EugeneDraitsev
Copy link
Author

Hmm, it still fails with 3.0.6

@hobbes7878
Copy link
Collaborator

hobbes7878 commented Aug 1, 2023

OK, I think the issue is you'll need your moduleResolution set to node16 or nodenext in your tsconfig for TypeScript to properly pickup the exported types.

Can you try that @EugeneDraitsev / @olafurw?

@olafurw
Copy link

olafurw commented Aug 1, 2023

It works but moduleResolution is something that is set by Svelte in the .svelte-kit/tsconfig.json file to be "moduleResolution": "node" so this isn't a fix but a workaround I would say.

How can anyone install the addon-svelte-csf and start using it when they also have to add a configuration line to their tsconfig.json file?

@hobbes7878
Copy link
Collaborator

I won't pretend to be an expert in these settings, but looking at the TS docs on moduleResolution, this might actually make a good argument that svelte-kit's tsconfig should be node16 or nodenext since their Node support range is ^16.14 || >=18.

Will check over there and see what's what.

@hobbes7878
Copy link
Collaborator

OK, so turns out they've had this discussion over the fence and landed on: sveltejs/kit#9007 (comment)

... which is sticking with node (now node10) until the new bundler setting comes in 5.0.

That's fine, but I hear @olafurw on the awkwardness of changing the typescript settings just for this package.

I think we could safely add back the main and types fields to package.json and then we're all living in happy harmony with both modern exports and classic options.

Gonna test that and make a PR.

@JReinhold
Copy link
Collaborator

Hope this is fixed now in 3.0.7, if not we'll reopen this issue.

Thanks for being very quick about this @hobbes7878, @EugeneDraitsev and @olafurw .

@EugeneDraitsev
Copy link
Author

Thank you for the super quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants