Skip to content
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

Documentation for io-ts types #201

Closed
singharpit94 opened this issue Aug 21, 2018 · 2 comments
Closed

Documentation for io-ts types #201

singharpit94 opened this issue Aug 21, 2018 · 2 comments

Comments

@singharpit94
Copy link

Hi,
I am using io-ts for defining my types and use them for run time validations. I would like to generate documentation for my types which can help users to know about the types and shape of interface.

For example for an interface like this

const someInterface = t.exact(t.interface({
    /**
     * Id of interface
     */
    id: t.string,
    /**
     * name of some property
     */
    name: t.string,
    /**
     * renderer for some component
     */
    customRenderer: ReactElement,
    /**
     * some custom type example
     */
    someProperty: customType,

}));

I want to generate documentation which contains the comments for the property to be used as their description and also the types associated with them.

Is there any support for generating the documentation for these types of interfaces.

@mmkal
Copy link
Contributor

mmkal commented Oct 31, 2018

this works for me already in vscode:
image

@gcanti
Copy link
Owner

gcanti commented Oct 31, 2018

@mmkal I didn't know that, looks like mapped types preserve JSDoc comments

declare function f<O>(o: O): { [K in keyof O]: null }

const x = f({
  /** name documentation */
  name: 'foo'
})

x.name // <= hover on `name`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants