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

Svelte component documentation not generated when using inline arrow functions (() => () => {}) #14162

Closed
jogarijo opened this issue Mar 7, 2021 · 1 comment

Comments

@jogarijo
Copy link

jogarijo commented Mar 7, 2021

Describe the bug
In a Svelte project, Storybook fails to generate a component documentation when it contains nested inline arrow functions (i.e. () => () => {}).

To Reproduce
Steps to reproduce the behavior:

  1. Create a simple Svelte project with Storybook. You can bootstrap one using npx degit chromaui/intro-storybook-svelte-template taskbox for example;
  2. Install dependencies;
  3. Run storybook (npm run storybook or yarn storybook);
  4. In any Svelte file, add an arrow function like in the "Code snippets" section below in one of the components;
  5. You should see an error in the console (see "Additional context"). Additionally, the component documentation will be empty.

Expected behavior
There should be no error

Code snippets

<script>
const foo = () => () => {} // fails
// works
const bar = () => {
  return () => {}
}}
</script>

System

  Binaries:
    Node: 14.8.0
    Yarn: 1.22.10
    npm: 6.14.7
  npmPackages:
    @storybook/addon-docs: ^6.1.21 => 6.1.21 
    @storybook/addon-essentials: ^6.1.21 => 6.1.21 
    @storybook/addon-links: ^6.1.21 => 6.1.21 
    @storybook/svelte: ^6.1.21 => 6.1.21 

Additional context
The following error is displayed by Webpack during the build:

TypeError: nodes.forEach is not a function
    at Parser.parseBodyRecursively (<path>/node_modules/sveltedoc-parser/lib/v3/parser.js:251:15)
    at <path>/node_modules/sveltedoc-parser/lib/v3/parser.js:331:38
    at Array.forEach (<anonymous>)
    at <path>/node_modules/sveltedoc-parser/lib/v3/parser.js:311:27
    at Array.forEach (<anonymous>)
    at Parser.parseBodyRecursively (<path>/node_modules/sveltedoc-parser/lib/v3/parser.js:251:15)
    at Parser.parseScriptBlock (<path>/node_modules/sveltedoc-parser/lib/v3/parser.js:571:14)
    at <path>/node_modules/sveltedoc-parser/lib/v3/parser.js:72:22
    at Array.forEach (<anonymous>)
    at Parser.__walk (<path>/node_modules/sveltedoc-parser/lib/v3/parser.js:71:36)
    at <path>/node_modules/sveltedoc-parser/lib/v3/parser.js:56:22

This error occurs in sveltedoc-parser in versions <4.1.0. Storybook uses version 3.0.5, and forcing the dependency to ^4.1.0 seem to solve the issue.

@jogarijo jogarijo changed the title Svelte compontent documentation not generated when using inline arrow functions (() => () => {}) Svelte component documentation not generated when using inline arrow functions (() => () => {}) Mar 7, 2021
@shilman
Copy link
Member

shilman commented Mar 8, 2021

Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-beta.11 containing PR #14164 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Mar 8, 2021
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

3 participants