jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

Storybook - Cannot add comment to a function in .ts file #661

Closed balazsorban44 closed 4 years ago

balazsorban44 commented 4 years ago

Current Behavior

I have a setup with Storybook, from the official template. When I try to add a comment to my function, storybook throws the following error: image The file has only 43 lines of code, so the second error does not even make sense to me. It only occurs, if the function is exported.

/** This comment is fine */
const foo = () => {}

Empty comment also works, even if exported (either named or default export works)

/** */
export const foo = () => {}

Any comment with export (either named or default) fails.

/** This comment gives the above mentioned error */
const foo = () => {}
export default foo

Expected behavior

Should allow adding comments to functions

Suggested solution(s)

This is a bug I have never come across, so I have no idea how to fix it.

Additional context

I only did one change to the original template, I like to keep related code next to each other, so I changed the folder structure:

src/
    |_Foo/
       |_index.tsx
       |_the_file_with_the_function_that_throws_error_on_comment.ts
       |_index.stories.tsx
The `.storybook/main.js` file:
  module.exports = {
    stories: ['../src/**/*.stories.(ts|tsx)'],
    addons: ['@storybook/addon-actions', '@storybook/addon-links', '@storybook/addon-docs'],
    webpackFinal: async (config) => {
      config.module.rules.push({
        test: /\.(ts|tsx)$/,
        use: [
          {
            loader: require.resolve('ts-loader'),
            options: {
              transpileOnly: true,
            },
          },
          {
            loader: require.resolve('react-docgen-typescript-loader'),
          },
        ],
      });
      config.resolve.extensions.push('.ts', '.tsx');
      return config;
    },
  };

Your environment

Software Version(s)
TSDX 0.13.1
TypeScript 3.8.3
Browser 83.0.4093.3 dev (64-bit)
npm/Yarn 6.9.0/1.21.1
Node 12.6
Operating System Linux 19.10
agilgur5 commented 4 years ago

Sorry but as you've said yourself, this is an issue with Storybook, not TSDX, so sounds you've filed this issue in the wrong repo.

TSDX doesn't use Storybook, it just provides a template for you to use it. Please file an issue with Storybook if you're having an issue with Storybook.