hipstersmoothie / react-docgen-typescript-plugin

A webpack plugin to inject react typescript docgen information
MIT License
68 stars 28 forks source link

TypeError: typescript_1.default.createIdentifier is not a function (ts 5.0.0-beta) #78

Closed Jack-Works closed 1 year ago

Jack-Works commented 1 year ago

ts.createIdentifier is deprecated (use ts.factory.create* instead).

See: https://github.com/microsoft/TypeScript/issues/51362#issuecomment-1408126388

jakebailey commented 1 year ago

This seems to have already been fixed: https://github.com/hipstersmoothie/react-docgen-typescript-plugin/commit/b6b5d0615e666bee3c931b3e1c1d5b490257fcea

(Unless this didn't get them all.)

Jack-Works commented 1 year ago

oh, thanks! looks like @storybook/react does not use the latest version of this library

Jack-Works commented 1 year ago

they pinned to 1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0 so does not include that change.

Jack-Works commented 1 year ago

oh sorry please release a new version on npm

Klathmon commented 1 year ago

@Jack-Works It seems like storybook has their own wrapper of this project (called @storybook/react-docgen-typescript-plugin) which is pinned to version 1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0.

This library is working fine and has been for a while, however the storybook-re-published version is still using an old version without the fix.

https://www.npmjs.com/package/@storybook/react-docgen-typescript-plugin

They list this repo as the source, but this repo says to install it via react-docgen-typescript-plugin not @storybook/react-docgen-typescript-plugin.

So storybook must re-publish their package, or switch to using the react-docgen-typescript-plugin directly. And it looks like they have a PR open as well (I finally found the forked repo here: https://github.com/storybookjs/react-docgen-typescript-plugin/pull/8).

And for anyone having this exact error using storybook with ts-5.0 beta before it's fixed, you can work around it by doing:

codinsonn commented 1 year ago

I'm on Storybook 6 and setting the following in main.js doesn't really seem to do anything, storybook just keeps using it's own fork regardless

typescript: {
    reactDocgen: 'react-docgen-typescript-plugin'
  },
targeral commented 1 year ago

@Jack-Works It seems like storybook has their own wrapper of this project (called @storybook/react-docgen-typescript-plugin) which is pinned to version 1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0.

This library is working fine and has been for a while, however the storybook-re-published version is still using an old version without the fix.

https://www.npmjs.com/package/@storybook/react-docgen-typescript-plugin

They list this repo as the source, but this repo says to install it via react-docgen-typescript-plugin not @storybook/react-docgen-typescript-plugin.

So storybook must re-publish their package, or switch to using the react-docgen-typescript-plugin directly. And it looks like they have a PR open as well (I finally found the forked repo here: storybookjs#8).

And for anyone having this exact error using storybook with ts-5.0 beta before it's fixed, you can work around it by doing:

  • npm i --save-dev react-docgen-typescript-plugin to install this package
  • add this to your main.js (or main.ts) file for storybook:
  typescript: {
    reactDocgen: 'react-docgen-typescript-plugin'
  },

It seems that Storybook's ability to generate React Component API documents doesn't work. I try:

typescript: {
  reactDocgen: 'any-string',
},

The problem with upgrading to Typescript 5 is resolved, but the React Component API documentation functionality is also disabled, which is somewhat similar to the effect of using the none option.