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

Proper usage with Typescript #1605

Open
balanza opened this issue Jul 5, 2023 · 0 comments
Open

Proper usage with Typescript #1605

balanza opened this issue Jul 5, 2023 · 0 comments

Comments

@balanza
Copy link

balanza commented Jul 5, 2023

Version 14.0.2

Hi,

I'm working with Typescript and I'm wondering which is the proper way to deal with type specifications. Let me propose an example to better explain myself.

Example

The code below can also be found as a working example here: https://codesandbox.io/p/sandbox/nice-cloud-3rxyg8

Suppose the following code:

// index.ts
type Address = { street: string; city: string };
type Email = { email: string };
type Phone = { phone: string };

/**
 * My User lorem ipsum
 */
export type User = {
  name: string;
  address: Address;
  contacts: Email & Phone;
};

/**
 * An example of person lorem ipsum
 */
export interface Person {
  name: string;
  surname: string;
  address: Address;
}

and suppose the following command:

$ documentation readme src/index.ts --parse-extension ts  --section=API

I receive the following output (in my README.md file):

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

*   [User](#user)
    *   [Properties](#properties)
*   [Person](#person)

### User

My User lorem ipsum

Type: {name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), address: Address, contacts: any}

#### Properties

*   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
*   `address` **Address**&#x20;
*   `contacts` **any**&#x20;

### Person

An example of person

Expectations

I spotted some issues in the outcome. I don't know if they are because of a misuse by myself, a known bug, a missing feature, or a feature documentation.js won't support at all. I read the docs and I found no clues about the will to support Typescript types and any known issues.

  1. Person members aren't listed just because it's written as an interface instead of a type
  2. User.address is of type Address, which is not meant to be exposed; Shouldn't it be expanded in the property definition?
  3. User.contacts isn't resolved because of the intersection &
  4. How can I add a description text for each property?

Apologize if any of these issues were already documented.

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

1 participant