jaredpalmer / tsdx

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

Storybook / React Docgen Typescript Plugin error: `trim is not a function` #1043

Open luigiminardim opened 3 years ago

luigiminardim commented 3 years ago

Current Behavior

I have created a package using tsdx create package-name with the storybook option. But, when I run the command yarn storybook, I receive the following error:

70% sealing React Docgen Typescript Plugin/home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:475
            var trimmedText = (tag.text || '').trim();
                                               ^

TypeError: (tag.text || "").trim is not a function
    at /home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:475:48
    at Array.forEach (<anonymous>)
    at Parser.getFullJsDocComment (/home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:474:14)
    at Parser.findDocComment (/home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:443:28)
    at Parser.getComponentInfo (/home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:177:23)
    at /home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:895:30
    at Array.forEach (<anonymous>)
    at /home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:894:20
    at Array.reduce (<anonymous>)
    at parseWithProgramProvider (/home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:886:10)
    at Object.parseWithProgramProvider (/home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript/lib/parser.js:75:20)
    at processModule (/home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript-plugin/dist/plugin.js:18:34)
    at /home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript-plugin/dist/plugin.js:97:49
    at Array.forEach (<anonymous>)
    at /home/luigi/Desktop/tsdx-test/node_modules/react-docgen-typescript-plugin/dist/plugin.js:97:34
    at SyncHook.eval [as call] (eval at create (/home/luigi/Desktop/tsdx-test/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:19:1)
error Command failed with exit code 1.

Screenshot from 2021-06-09 13-03-27

Expected behavior

yarn storybook should work in fresh projects.

Your environment

  System:
    OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
    Memory: 2.93 GB / 15.51 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.16.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.12.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 91.0.4472.77
    Firefox: 89.0
  npmPackages:
    tsdx: ^0.14.1 => 0.14.1 
    typescript: ^4.3.2 => 4.3.2 
  npmGlobalPackages:
    tsdx: 0.14.1
heronsousa commented 3 years ago

Same issue here

monsieurBoutte commented 3 years ago

same

70% sealing React Docgen Typescript Plugin/Users/victorboutte/wistia/the-editor/node_modules/react-docgen-typescript/lib/parser.js:475
            var trimmedText = (tag.text || '').trim();
                                               ^

TypeError: (tag.text || "").trim is not a function

the workaround to get this running for me, was to dive into react-docgen-typescript/lib/parser.js:475 and remove the .trim() call

monsieurBoutte commented 3 years ago

created an issue for this in react-docgen-typescript repo

robiXxu commented 3 years ago

same issue here.

robiXxu commented 3 years ago

Seems like they fixed it and it was merged 5 days ago. https://github.com/styleguidist/react-docgen-typescript/issues/356

robiXxu commented 3 years ago

There's a workaround : https://github.com/styleguidist/react-docgen-typescript/issues/356#issuecomment-850400428