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

__namedParameter Properties are not showing in documentation if exported interfaces are used to describe them #2456

Closed
amkuchta opened this issue Dec 6, 2023 · 1 comment
Labels
bug Functionality does not match expectation duplicate This duplicates another issue

Comments

@amkuchta
Copy link

amkuchta commented Dec 6, 2023

Search terms

__namedParameters interface typedoc typescript param

Expected Behavior

I have an interface defined ina file that is exported and able to be imported throughout my project:

/**
 * Wrapper for required arguments to parse a JSON `object`
 * into a specified class
 *
 * @typeParam T - The type of the class to be parsed into
 * @param {string} input - The JSON `object` to be parsed
 * @param {ClassConstructor<T>} type - The type of the class
 * to be parsed into
 */
export interface IFromJsonInput<T> {
  input: string;
  type: ClassConstructor<T>;
}

I use this interface to describe an object that is used as the parameter for a function within a class:

/**
 * Provides a common base set of properties and instructions that all inheriting
 * classes can utilize.
 *
 * @remarks
 * Designed to reduce boilerplate code, this class provides common properties and
 * functions that can be utilized by all classes; this includes information on who
 * interacted with the object (to be used for database storage) and methods to
 * allow a developer to convert the object to/from JSON. Routines also exist to
 * clone the object and validate it using
 * {@link https://github.com/typestack/class-validator | class-validator}.
 *
 * @typeParam T - The inheriting object type
 *
 * @example
 * ```ts
 * export class ExampleClass extends BaseClass<ExampleClass> {
 *   ...
 * }
 * ```
 */
export abstract class BaseClass<T> implements ISerializable<T>, IEntityBase {
/**
   * Converts a valid JSON object to an instance of the inheriting class
   *
   * @typeParam T - The type of the inheriting object
   *
   * @param {IFromJsonInput} __namedParameters
   * @param {string} __namedParameters.input - The object to be converted into the
   * inheriting class
   * @param {ClassConstructor<T>} __namedParameters.type - The type of the inheriting class
   *
   * @returns {T} T - An instance of the inheriting class
   *
   * @example
   * ```ts
   * let json: object = {...}
   * let exampleClass: ExampleClass = new ExampleClass().fromJson({
   *                                                                input: json,
   *                                                                type: ExampleClass
   *                                                             })
   * ```
   */
  fromJson({ input, type }: IFromJsonInput<T>): T {
    return plainToInstance(type, input);
  }
}

When I generate the docs using TypeDoc, the __namedParameter is listed, but the two items within it are not:

image

Actual Behavior

I would expect to see the enumerated items in __namedParameters listed out in the documentation for the function, as implemented in the comment.

Steps to reproduce the bug

  1. Create an interface
  2. Create a function within a class
  3. Use the interface to describe the parameter for the function
  4. Add comments
  5. Run the documentation command
    - Mine is npx typedoc --plugin typedoc-theme-hierarchy --theme hierarchy --plugin typedoc-plugin-extras --plugin typedoc-plugin-coverage --plugin typedoc-plugin-remove-references

####Installed Versions:

  • TypeScript: ^5.3.2
  • TypeDoc: ^0.25.4
  • typedoc-plugin-extras: ^3.0.0
  • typedoc-plugin-coverage: `^2.2.0
  • typedoc-plugin-remove-references: ^0.0.6
  • typedoc-theme-hierarchy: ^4.1.2

tsconfig.json

{
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "target": "ES6",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "baseUrl": "./src",
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

typedoc.json

{
  "$schema": "https://typedoc.org/schema.json",
  "entryPoints": ["src"],
  "entryPointStrategy": "expand",
  "out": "public/docs",
  "tsconfig": "./tsconfig.json",
  "name": "React TypeScript TailwindCSS Components",
  "exclude": [
    "node_modules/**/*.*",
    "node_modules",
    "**/node_modules/**",
    "**node_modules/**/*.*"
  ]
}

TypeDoc Command

npx typedoc --plugin typedoc-theme-hierarchy --theme hierarchy --plugin typedoc-plugin-extras --plugin typedoc-plugin-coverage --plugin typedoc-plugin-remove-references

Environment

  • Typedoc version: ^5.3.2
  • TypeScript version: ^0.25.4
  • Node.js version: v20.9.0
  • OS: Windows
@amkuchta amkuchta added the bug Functionality does not match expectation label Dec 6, 2023
@Gerrit0 Gerrit0 added the duplicate This duplicates another issue label Dec 17, 2023
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 17, 2023

Duplicate of #2147, which apparently I never pressed comment on my response to...

TypeDoc doesn't do this today as parameter display is tied to the type display. There's a proposed fix for the linked issue which I don't much like because it essentially hacks around this by adding extra @param tags on the parameter.

It also needs more design consideration for edge cases:

  • What happens if you specify a property that doesn't exist on the linked type? What if there's an index signature on the linked type?
  • What happens if you don't specify every property on the linked type?
  • What happens if the linked type doesn't actually exist as far as TypeDoc is concerned? (Marked with @ignore, present in some declaration file that's excluded with --excludeExternals)
  • What if the linked type isn't an object? What if it's an intersection of objects? A union?

@Gerrit0 Gerrit0 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation duplicate This duplicates another issue
Projects
None yet
Development

No branches or pull requests

2 participants