Docz: Advanced typescript annotation integration

Created on 12 Jun 2018  ·  3Comments  ·  Source: doczjs/docz

Hi,

Thank you so much for Docz, I always had issues with other tools, and Docz just work. The Typescript integration with PropsTable is awesome and I'd just like to open discussion on some more advanced integration:

  • Support default value with JS default function parameters, ie function MyComponent({text = "hello"}) {}
  • Support description with JS comment above the parameter, as currently handled by the typescript language server used in IDEs, ie
    ```js
    function MyComponent({
    /*

    • Documentation for the “text” parameter

      *
      /

      text = "hello"

      })

  • Support normal functions, and not exclusively React components, including with parameters typing and inline parameter documentation.

Voilà, I'm sure you already though of these items but I though it would be good to have an open discussion on it.

question

Most helpful comment

Glad you liked it @mquandalle. I'm using typescript a lot in a bunch of projects nowadays, to be honest, I'm using it for all projects and I really like it. Unfortunately, since I did not have much time, I ended up choosing to get some tool that makes this annotation integration already. In this version of docz we're using react-docgen to generate the properties table, but it is kinda limited, have a lot of trade-offs and can be a performance problem 😢One of these trade-offs is about default properties using typescript. Flow integration is so much better than typescript!

Maybe in future is good thing create something or improve react-docgen to fix these problems.

About annotations in normal functions, this is awesome and I think that is something really easy and viable to do with docz. I'm thinking about that this week and JSDocs until now is the better alternative!

All 3 comments

Glad you liked it @mquandalle. I'm using typescript a lot in a bunch of projects nowadays, to be honest, I'm using it for all projects and I really like it. Unfortunately, since I did not have much time, I ended up choosing to get some tool that makes this annotation integration already. In this version of docz we're using react-docgen to generate the properties table, but it is kinda limited, have a lot of trade-offs and can be a performance problem 😢One of these trade-offs is about default properties using typescript. Flow integration is so much better than typescript!

Maybe in future is good thing create something or improve react-docgen to fix these problems.

About annotations in normal functions, this is awesome and I think that is something really easy and viable to do with docz. I'm thinking about that this week and JSDocs until now is the better alternative!

I really don't know much about meta analyse of JS files, but do you think it might be viable to use the typescript language server (for both TS and JS files) to gather meta informations like types and field descriptions using the same API than IDE like VS Code?

The idea would be to use a mature high level API instead of transforming AST.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ssylvia picture ssylvia  ·  3Comments

bichotll picture bichotll  ·  3Comments

mariusespejo picture mariusespejo  ·  3Comments

brunolemos picture brunolemos  ·  3Comments

kachkaev picture kachkaev  ·  3Comments