-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add TypeScript support via Babel 7 #4587
Comments
I am also trying to add support for that via Babel. How did you get around the I already installed @babel/core instead of babel-core Edit: figured it out, I was missing to upgrade babel-loader to v8.0.0 |
(I updated the configuration above. I have it working with it, except for decorators which require an additional plugin) |
Great idea @GeeWee , PR is welcome |
Trying to do this just yesterday with a create-react-app with Typescript enabled and encountered that baseurl isn't handled well, or is isn't compatible with create-react-app's required parameters (such as noemit) even with the above tweaks. |
Now that this is official in CRA, it would be great to add this out-of-the-box. |
Just adding this resolved the issue for me.
However, the docs suggest the following:
If we're OK with this approach, I can put together a PR that looks for a tsconfig.json in root, and if present, adds support in the same way that we do for CSS modules (below). |
The config above works for me as well. Note that you'll have to make a decision whether or not to support decorators, they're a separate plugin. |
I think we should (by default) follow the approach used by CRA - so when we detect Otherwise, users can do what they could always do and extend. Edit: I'll work on this today and submit a PR ;) |
@mrmckeb this one worked for me:
Thanks! |
Hi all, if anyone would like to take a look at #4824 and leave feedback, please do. It's works perfectly for me when testing locally. |
Released as 4.1.0-alpha.7 https://github.com/storybooks/storybook/releases/tag/v4.1.0-alpha.7 |
This doesn't support the config files as TypeScript. For this:
to work I still need to add
|
@Itrulia It was never intended to sorry, this was intended for project files, and I never tested for or thought to support this. Apologies if this caused you any inconvenience. I'm concerned that your change suggested above could be an issue as it would force all typescript to be passed by rule[0], which is not the rule for CRA. @igor-dv This could be an order of operations issue. Should we add the CRA config earlier? |
I assume it happens because CRA includes only files from |
@igor-dv Maybe that's best. To limit the impact, we could specifically add the |
Take your time 👍 thanks |
Is it also going to be configurable via the edit: Also thanks for looking in to it 👍 |
It should =) |
The fix is merged. |
Seeing as adding TypeScript support via Babel 7 is getting a lot of traction (see e.g. facebook/create-react-app#4837 for a high profile example), it would be nice for Storybook to support this possibility out of the box.
What I expect to be possible, is for me to add the proper values to my .babelRc and for Storybook to then be able to compile TypeScript to JS.
Example .babelrc
However this does not work. Storybook only applies these rules to javascript files in the webpack configuration. You also have to create a corresponding webpack configuration file:
Would it be possible to include the typescript files in the test and the extensions per default? I can't see any downside for people not using typescript, as nothing will change for them.
The text was updated successfully, but these errors were encountered: