strothj / react-docgen-typescript-loader

Webpack loader to generate docgen information from Typescript React components.
Other
360 stars 47 forks source link

Typescript errors #83

Closed Pitbi closed 3 years ago

Pitbi commented 4 years ago

Hello,

During the storybook build, I have the following errors when I don't use semicolons in my code.

ERROR in [at-loader] ./src/components/title/index.tsx:41:25 
    TS1005: ';' expected.

ERROR in [at-loader] ./src/components/title/index.tsx:51:1 
    TS1005: 'try' expected.

ERROR in [at-loader] ./src/components/title/index.tsx:14:7 
    TS6133: 'Title' is declared but its value is never read.

ERROR in [at-loader] ./src/components/title/index.tsx:41:16 
    TS2304: Cannot find name 'Titletry'.

In this case, I solved the issue by adding semicolons to title/index.tsx . If I remove react-docgen-typescript-loader, it "works" too but it's not the goal. :) My storybook config is identical to that presented in the official storybook doc.

An idea?

Thx in advance.

dgreene1 commented 4 years ago

One solution would be to run prettier on save or before compilation. I haven't tried it yet myself. What I did instead was to set an eslint rule to enforce semicolons (which I'd rather not do, but it prevents this issue).

strothj commented 4 years ago

Can someone provide a reproduction for this? If I had to guess, there’s a minor Webpack tweak that can be done to resolve this.

balazsorban44 commented 4 years ago

I came across the same problem,

You can see my config here: https://github.com/storybookjs/storybook/issues/10395#issue-598479946

Pitbi commented 4 years ago

Sorry for the late response. I finally stopped using storybook, but the config of @balazsorban44 is very close to mine and I had exactly the same error.

elicayuu commented 4 years ago

I encountered same problem. Solved this problem by add newline at the end of files. So I put eol-last rule into eslint.

buhichan commented 3 years ago

I think it should also work for those who don't like use eol-last rule. So I create a fix by adding a \n between the sourcefile and the try-catch block.