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
Support TypeScript out of the box #750
Comments
## New features * New option `editorConfig` to change CodeMirror options (#648, [#662](#662) by @SaraVieira) * Allow descriptions for sections ([#743](#743) by @SaraVieira) * Add TypeScript files to default components and ignore patterns ([#749](#749), part of [#750](#750)) ## Bug fixes * Fix global access to all components in isolation mode ([#738](#738)) * Fix color issue in Safari ([#739](#739)) * Allow overriding of renderer-only components ([#710](#710)) * Do not overflow floated elements in examples (#772, [#773](#773) by @roblevintennis) * HTML escaping in Add example block ([#741](#741)) * Fix infinite loop caused by markdown-to-jsx ([#742](#742))
## New features * New option `editorConfig` to change CodeMirror options (#648, [#662](#662) by @SaraVieira) * Allow descriptions for sections ([#743](#743) by @SaraVieira) * Add TypeScript files to default components and ignore patterns ([#749](#749), part of [#750](#750)) ## Bug fixes * Fix global access to all components in isolation mode ([#738](#738)) * Fix color issue in Safari ([#739](#739)) * Allow overriding of renderer-only components ([#710](#710)) * Do not overflow floated elements in examples (#772, [#773](#773) by @roblevintennis) * HTML escaping in Add example block ([#741](#741)) * Fix infinite loop caused by markdown-to-jsx ([#742](#742))
## New features * New option `editorConfig` to change CodeMirror options (#648, [#662](#662) by @SaraVieira) * Allow descriptions for sections ([#743](#743) by @SaraVieira) * Add TypeScript files to default components and ignore patterns ([#749](#749), part of [#750](#750)) ## Bug fixes * Fix global access to all components in isolation mode ([#738](#738)) * Fix color issue in Safari ([#739](#739)) * Allow overriding of renderer-only components ([#710](#710)) * Do not overflow floated elements in examples (#772, [#773](#773) by @roblevintennis) * HTML escaping in Add example block ([#741](#741)) * Fix infinite loop caused by markdown-to-jsx ([#742](#742))
I do not want to open an separate issue, because I'm not sure if this an issue of My config is: const path = require("path");
module.exports = {
propsParser: require("react-docgen-typescript").withCustomConfig(
"./tsconfig.json"
).parse
}; I get the following error
UPD: fixed by adding this to the config
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@sapegin I might need this and could work on this. I'm not sure about the second step, though. Any pointers? |
@okonet Probably that's what |
I think that's done by now.
Seems to work.
I need a spec for this. How should we depend on react-docgen-typescript? What's the preferred approach? It doesn't come with any deps and it's controlled. I have a basic setup to adapt. |
I think your approach with extension checking is the right one! |
I'm not sure about that after looking at the code ;-/ |
Yep, we should resolve the path carefully. |
I was doing a little bit of research on this and it looks like react-docgen is trying to support typescript, but it seems to be in early stages. If they did support TS there would not be a need for react-docgen-typescript anymore.
Seems doable, just update props-loader.js to check if TS is supported then use react-docgen-typescript if it is. |
In case you are still considering this, I would recommend you run react-docgen-typescript against some slightly complex cases such as a formerly Flow-typed FC that destructures props, assigns default values to them and uses typed objects for some of the props - some of which are optional. Unfortunately, none of that works well, as I have discovered today, after migrating our UI component library at work from Flow to TS. Default values are missing, the structure of typed objects is not passed to styleguidist and optional props are described as But that's why I'd recommend waiting for that react-docgen TS support that @tsiq-jeremy mentioned. |
The beautiful thing is... possibly due to babel magic (gotta love it), it looks like people who need TS support right now can actually already have it. I've played around with the Looks just wonderful to me. Not sure whether it has any flaws but... I'll definitely try this out on our library at work soon. 😉 UPDATE Yup, works great as long as one uses |
FYI, I'm working on TypeScript support for react-docgen here. Feel free to test it out: reactjs/react-docgen#348 |
Should this also include support for customizing rsg-components? Got typescript working fine for presented components, but creating custom rsg-components with |
@J-Kallunki which problems do you have? There shouldn't be any difference ;-/ |
I'm using Webpack and awesome-typescript-loader.
Typings (minimal):
Result:
So I would need to configure babel just for it and use only non-TS custom components? |
I don't think you need to configure Babel, everything in |
I got the earlier example working just by defining to
Is it the best way to do it - it is the simplest - or should it be also documented how to use custom srg components with TS? |
Have you tried this?
|
Yeah tried that with the same way as it works for the It is clearly saying that cannot find
|
@J-Kallunki I may have fixed that in 9e29c10, at least I had the same error ;-) |
The error:
I am not certain this is the same issue, apologies if not. I'm using create-react-app, I made a tsx
I created the smallest reproduction of this that I could and made a repo here. https://github.com/plumpNation/cra-styleguidist-typescript Thanks for the excellent tool, I will just switch the wrapper to jsx until I find out how to support tsx styleguideComponents. EDIT: I switched to jsx and I still have the "missing loader" error so I may be doing something very wrong. EDIT2: I had a break and it occurred to me that the styleguideComponents probably need to be in the standard CRA I'll let you delete or allow this comment to remain. Again, thanks for the library. |
## New features * New option `editorConfig` to change CodeMirror options (#648, [#662](styleguidist/react-styleguidist#662) by @SaraVieira) * Allow descriptions for sections ([#743](styleguidist/react-styleguidist#743) by @SaraVieira) * Add TypeScript files to default components and ignore patterns ([#749](styleguidist/react-styleguidist#749), part of [#750](styleguidist/react-styleguidist#750)) ## Bug fixes * Fix global access to all components in isolation mode ([#738](styleguidist/react-styleguidist#738)) * Fix color issue in Safari ([#739](styleguidist/react-styleguidist#739)) * Allow overriding of renderer-only components ([#710](styleguidist/react-styleguidist#710)) * Do not overflow floated elements in examples (#772, [#773](styleguidist/react-styleguidist#773) by @roblevintennis) * HTML escaping in Add example block ([#741](styleguidist/react-styleguidist#741)) * Fix infinite loop caused by markdown-to-jsx ([#742](styleguidist/react-styleguidist#742))
## New features * New option `editorConfig` to change CodeMirror options (#648, [#662](styleguidist/react-styleguidist#662) by @SaraVieira) * Allow descriptions for sections ([#743](styleguidist/react-styleguidist#743) by @SaraVieira) * Add TypeScript files to default components and ignore patterns ([#749](styleguidist/react-styleguidist#749), part of [#750](styleguidist/react-styleguidist#750)) ## Bug fixes * Fix global access to all components in isolation mode ([#738](styleguidist/react-styleguidist#738)) * Fix color issue in Safari ([#739](styleguidist/react-styleguidist#739)) * Allow overriding of renderer-only components ([#710](styleguidist/react-styleguidist#710)) * Do not overflow floated elements in examples (#772, [#773](styleguidist/react-styleguidist#773) by @roblevintennis) * HTML escaping in Add example block ([#741](styleguidist/react-styleguidist#741)) * Fix infinite loop caused by markdown-to-jsx ([#742](styleguidist/react-styleguidist#742))
## New features * New option `editorConfig` to change CodeMirror options (#648, [#662](styleguidist/react-styleguidist#662) by @SaraVieira) * Allow descriptions for sections ([#743](styleguidist/react-styleguidist#743) by @SaraVieira) * Add TypeScript files to default components and ignore patterns ([#749](styleguidist/react-styleguidist#749), part of [#750](styleguidist/react-styleguidist#750)) ## Bug fixes * Fix global access to all components in isolation mode ([#738](styleguidist/react-styleguidist#738)) * Fix color issue in Safari ([#739](styleguidist/react-styleguidist#739)) * Allow overriding of renderer-only components ([#710](styleguidist/react-styleguidist#710)) * Do not overflow floated elements in examples (#772, [#773](styleguidist/react-styleguidist#773) by @roblevintennis) * HTML escaping in Add example block ([#741](styleguidist/react-styleguidist#741)) * Fix infinite loop caused by markdown-to-jsx ([#742](styleguidist/react-styleguidist#742))
components
andignore
patterns to include.ts
and.tsx
..ts
and.tsx
.typescript
and see if the information is still relevant).The text was updated successfully, but these errors were encountered: