Skip to content

No support for exported flow types #359

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

Closed
trodrigues opened this issue Feb 18, 2016 · 4 comments · Fixed by #619
Closed

No support for exported flow types #359

trodrigues opened this issue Feb 18, 2016 · 4 comments · Fixed by #619
Assignees
Labels

Comments

@trodrigues
Copy link

When splitting and reusing types between multiple modules, it's common to use Flow's export type syntax.

This doesn't seem to be actually documented but it's explained in this blog post: http://flowtype.org/blog/2015/02/18/Import-Types.html

Right now, documentation.js seems to only infer the name from these kinds of declarations. So if you have something like:

/**
 * Define my object API
 */
export type SomeObjectAPI = {
  method: (param: string) => boolean
}

the generated documentation only shows something like:

SomeObjectAPI
Define my object API

However, if I were to do something like

/**
 * Define my object API
 */
type SomeObject = {
  method: (param: string) => boolean
}
export type SomeObjectAPI = SomeObject

it would work fine.

@ajhyndman
Copy link

It seems to me like this is a more general issue, in fact.

Using the export keyword inline with a documented feature, seems to cause a failure in documentation.js's parser. Signature information for that code feature appears to get garbled.

I set up a small demo demonstrating this:
ajhyndman/documentation-js-demo@6dee0bd

@tmcw
Copy link
Member

tmcw commented Nov 18, 2016

Thanks for the testcase @ajhyndman. Going to look into a cause for this.

@tmcw
Copy link
Member

tmcw commented Nov 18, 2016

Okay, so in the case of:

/**
 * Return a number multiplied by two.
 * @memberof main
 * @param a A number to be doubled
 * @returns The input number, doubled
 */
function double (a: number): number {
  // Do some stuff
  return a * 2;
}

This is that right now we intelligently let you specify @param in the document tag and then 'enhance' it by adding flow-inferred typing to it. We don't do the same thing with @returns - if you specify the documentation tag, we don't try to infer its type. We should.

That said, this is a different issue than the OP, since this happens on the code irregardless of the exports keyword.

@tmcw
Copy link
Member

tmcw commented Nov 25, 2016

In current master/beta15, this bug persists: the output for the given example is

# SomeObjectAPI

Define my object API

Will have to look into this: I think the issue is that the template doesn't output the type of typedefs.

@tmcw tmcw self-assigned this Nov 25, 2016
@tmcw tmcw closed this as completed in #619 Nov 25, 2016
rhendric pushed a commit to rhendric/documentation that referenced this issue Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants