-
Notifications
You must be signed in to change notification settings - Fork 46
Webpack configuration fails to build typescript. #24
Comments
Hello, Can you post the contents of one of the files that is being reported as having a missing Can you try surrounding the affected code block in a |
Hi, We're running into the same problem and managed to narrow it down to tsx files that contain a |
More specifically; the issue happens when using
|
Done a bit more digging, and the cause seems to be that react-docgen-typescript sets docComment.displayName to it's best guess, which sometimes is just the filename, and react-docgen-typescript-loader uses this displayName as it's best guess for the symbol it attaches the __displayname and __docinfo properties to. Somehow I feel that react-docgen-typescript should be able to figure out the actual class or function name of the React component regardless of how it exports - and thus figure out the proper display name. That's the one part. But regardless of what react-docgen-typescript thinks about the displayName, the loader should not just blindly trust it to be a valid javascript variable name. Would a fix that assumes display name to be in kebab case, if it contains a hyphen be a good idea? I might find some time to work on a PR for that but I could do with some input about what a good fix would be. @sztrzask Can you confirm that the hyphen problem indeed also is the cause of the error you're getting? |
Can confirm that kebab case totally breaks stuff. Facing the same issue in my repo. |
Hello, thank you for the reports. The loader has an option to disable attaching displayName automatically. The purpose of attaching displayName is to prevent the component name from disappearing when the bundle has been minified/mangled in production. The info addon uses the display name to match the story description with one of the rendered components. You can try disabling the option and seeing if there is any change there. Right now I have a couple of client projects eating up my time but I intend to get this sorted out when I can. I'd be happy to accept a pull request if anyone feels adventurous. |
One thing that might be worth checking is seeing if Styleguidist with
This sounds reasonable. |
Using the {
loader: require.resolve('babel-loader')
},
{
loader: require.resolve('react-docgen-typescript-loader'),
options: { setDisplayName: false },
} It did not change a thing. Well, it did actually -- instead of Storybook loading up and then erroring, it instead gave me errors in the console, which is nice. Before I would get a blank Storybook (with the plugin). With the loader, I get the following console error (I've replaced the path to the file with ##PATH##)
So it appears it's definitely grabbing the docgenInfo correctly, it just gets confused when naming the variable. |
hey!, i hava some issuse about ** TS1005: ';' expected.** config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
require.resolve('awesome-typescript-loader'),
require.resolve('react-docgen-typescript-loader')
]
}, year,i searched solution i can; but no useful; config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('awesome-typescript-loader')
} dou you have any idea to resolve this problem ,my repo; thx |
Hi, update "react-docgen-typescript" to last version(1.12.2 ) will solve this issue |
@Yorkey thx for you solution, but it does not work; at the same times, i user 1.9.0 , it's behave likes before |
Uh oh!
There was an error while loading. Please reload this page.
Proposed webpack configuration fails to build typescript.
Random number of tsx files are reported with error TS1005: ';' expected. during storybok's build.
This is my tsconfig:
I am using create-react-app-ts and if I use the storybook's webpack configuration from storybook (https://storybook.js.org/configurations/typescript-config/) the code compiles and storybook starts, however it's using the older
plugin
instead ofloader
Any ideas?
The text was updated successfully, but these errors were encountered: