-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
storiesof-to-csf.js
codemod does not support Typescript (tsx in particular)
#9669
Comments
I forgot to mention that there was another issue: |
After a lot of debugging, I found a simple fix: change |
stories-to-csf.js
does not support Typescript (tsx in particular)storiesof-to-csf.js
codemod does not support Typescript (tsx in particular)
Thank you @mbylstra !!! 🙏🙏🙏 |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@mbylstra any chance you can contribute that PR? |
I started a branch but it was very unfinished and I haven't had a chance to revisit. The hard part was making the test suite (and refactoring it to run tests for Typescript as well as JS). The fix itself is just:
But then it will only work in Typescript, not JS, so it needs a conditional. I'm hoping I can prepare a proper PR in my next "cooldown" period at work, which will be in a couple of weeks. |
The issue with
while
A quick fix would be this:
But needs proper tranformation of a jscodeshift enum to the prettier enum. |
Additional issue with prettier is that it doesn't read options from |
@Vanuan can you submit a fix? |
is there an update for this? I tried
|
now with storybook 6 you have more reasons to run this migration, but is not possible because of this bug. |
PRs welcome! |
w00t!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.9 containing PR #12453 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Jeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.22 containing PR #12453 that references this issue. Upgrade today to try it out! |
Hi there! I just tried running this on a typescript codebase via Got this error:
|
it is still breaking for me |
@sibelius Do you have a repro repo you can share? |
import { storiesOf } from '@storybook/react';
import CandidateWelcomeEmail from './CandidateWelcomeEmail';
storiesOf('Candidate/Candidate Welcome Email', module)
.add('With no logo', () => (
<CandidateWelcomeEmail
readableId="567182678789"
/>
))
.add('With logo', () => (
<CandidateWelcomeEmail
readableId="567182678789"
/>
)); this is a tsx file, not sure if this break the codemod somehow |
I'm getting the same error trying to run I get the same stack of
regardless of what parser option I select (tsx, ts, babel, etc) |
update: this seems to have been because I was specifying some core-js settings in my babel.config.js file that was causing issues. Temporarily removing that config let the transform complete. Before: module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {},
useBuiltIns: 'usage', // include polyfills only on found usages of es6 in our code
corejs: { version: 3 }, // use core-js@3 for polyfills
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
}; After module.exports = {
presets: [
[
'@babel/preset-env',
{
// targets: {},
// useBuiltIns: 'usage', // include polyfills only on found usages of es6 in our code
// corejs: { version: 3 }, // use core-js@3 for polyfills
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
}; |
Describe the bug
storiesof-to-csf.js
does not support Typescript (tsx in particular)To Reproduce
Steps to reproduce the behavior:
Test.stories.tsx
./node_modules/.bin/jscodeshift --parser=tsx -t ./node_modules/@storybook/codemod/dist/transforms/storiesof-to-csf.js Test.stories.tsx
The script should run without errors, but you should see that the file
Test.stories.tsx
has not been upgraded. However, you should see that the lineimport { storiesOf } from "@storybook/react"
has been removed from the file, so the transform is doing something, but nothing more than that.Note: I haven't tried this is with
.ts
files, only.tsx
so I don't know if the problem is specific to.tsx
or.ts
and.tsx
Expected behavior
The test file should be completely upgraded to CSF format
The text was updated successfully, but these errors were encountered: