Skip to content

[api-extractor] Question: is it possible to generate documentation for augmented ambient types? #1656

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
jrnail23 opened this issue Dec 11, 2019 · 1 comment
Labels
enhancement The issue is asking for a new feature or design change

Comments

@jrnail23
Copy link

Just a question... I'm building a package of custom commands for Cypress, which generally extend a global variable (i.e., if I create a command called doSomething, you'd use it by calling cy.doSomething(), where cy is their built-in global variable).

In order to make them work with Typescript, you augment the existing Cypress interfaces by adding the appropriately typed method (relevant docs). Here's an example:

declare namespace Cypress {
  interface Chainable {
    /**
     * Custom command to select DOM element by data-cy attribute.
     * @example cy.dataCy('greeting')
    */
    dataCy(value: string): Chainable<Element>
  }
}

I'd like to figure out how to generate documentation from the typescript definitions, which, as you can see are generally ambient declarations, rather than exported types. Also, they may not generally be accessible via a single entry point.

Is it currently possible to generate docs for these types using api-extractor/api-documenter? If not, does anyone have any ideas for a clever workaround?

@octogonz octogonz added enhancement The issue is asking for a new feature or design change needs design The next step is for someone to propose the details of an approach for solving the problem and removed needs design The next step is for someone to propose the details of an approach for solving the problem labels Dec 11, 2019
@octogonz
Copy link
Collaborator

Today, API Extractor doesn't support:

Until both these problems are solved, I don't think we could consider implementing support for augmented ambient types.

I feel like the way to work around it would be to design a conventional API, and run API Extractor on that. Then have a entry point that converts it into a global variable. Take a look at @types/react for an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is asking for a new feature or design change
Projects
None yet
Development

No branches or pull requests

2 participants