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

Trim is not a function #42

Open
leepowelldev opened this issue Jun 9, 2021 · 12 comments
Open

Trim is not a function #42

leepowelldev opened this issue Jun 9, 2021 · 12 comments

Comments

@leepowelldev
Copy link

Having an issue with Typescript 4.3.2 and line 476 on parser.js

var trimmedText = (tag.text || '').trim();
...
TypeError: (tag.text || "").trim is not a function

I output the console and can see in certain scenarios that instead of getting:

{
  name: string,
  text: string
}

I am getting this kind of structure:

{
  name: 'see',
  text: [
    { text: 'https', kind: 'text' },
    {
      text: '://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute',
      kind: 'text'
    }
  ]
}

I'll try to dig deeper tonight to see if I can find out what is happening and try to create a simplified demo.

@leepowelldev
Copy link
Author

styleguidist/react-docgen-typescript#356

@luigiminardim
Copy link

Same issue here when trying to use TSDX with storybook.

@luigiminardim
Copy link

Is there any workaround?

@bebraw
Copy link
Contributor

bebraw commented Jun 10, 2021

The fix is to update https://www.npmjs.com/package/react-docgen-typescript to v2.0.0 (published two hours ago). Likely you can set it to the version through npm/yarn. I'll do a quick PR to fix it here as well.

@leepowelldev
Copy link
Author

@bebraw - great, thank you!

@bebraw
Copy link
Contributor

bebraw commented Jun 10, 2021

@leepowelldev It looks like v2.0.0 breaks parsing behavior a tiny bit (defaultValue for a snapshot isn't set now). It seems like there's more work to do for a proper fix but likely going with 2.0.0 would fix the trim issue. I'll try to figure out what's causing the regression.

@yanckst
Copy link

yanckst commented Jun 11, 2021

Yeah I agree that updating the library will probably fix the error.

Another related issue : #43

@hipstersmoothie
Copy link
Owner

@bebraw Thanks for handling this!

@sauldeleon
Copy link

Eyes on this! thanks!

@ptrhck
Copy link

ptrhck commented Jun 28, 2021

Could you merge this PR? :)

@bebraw
Copy link
Contributor

bebraw commented Jun 28, 2021

@ptrhck There's a regression in react-docgen-typescript that has to be solved before the update can be done. Here's more info: styleguidist/react-docgen-typescript#366 .

@ecraig12345
Copy link

@bebraw It's not exactly a regression; it's an issue with using react-docgen-typescript version 2 with typescript < 4.3. Version 2 had some jsdoc tag parsing changes that only work against >= 4.3, and its typescript peer dep range has been updated to reflect this.

#43 would fix the tag parsing issue by updating this package's typescript version and peer dep. Unfortunately this would also force everyone using this feature within storybook to upgrade to TS 4.3, which may not be feasible. (TS upgrades can be painful and time-consuming for large projects such as my team's and have to be balanced with other priorities; or sometimes upgrades are outright blocked by bugs which aren't resolved until the next minor version.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants