Skip to content

Support making type parameters private #1319

Closed
Closed
@d-fischer

Description

@d-fischer

Problem

Suppose I have a class like this (this is from my actual generated .d.ts but a bit simplified):

export default abstract class Subscription</** @protected */ T = any> {
    protected _handler: (obj: T) => void;
    /** @protected */
    constructor(_handler: (obj: T) => void);
    /**
     * Whether the subscription has been verified.
     */
    get verified(): boolean;
    /**
     * Activates the subscription.
     */
    start(): Promise<void>;
    /**
     * Suspends the subscription, not removing it from the listener.
     */
    suspend(): Promise<void>;
    /**
     * Deactivates the subscription and removes it from the listener.
     */
    stop(): Promise<void>;

    protected abstract transformData(response: object): T;
}

The Subscription class uses the T type parameter internally, but not at all in its public API.

For consumers reading the documentation, it might be unnecessarily confusing to include it.

Suggested Solution

Expose the @protected (or @private) tag in the output somehow.

(This is coming from the Discord conversation we had a few days ago, just wanna formalize the suggestion here and provide an example)

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixDeclining to implement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions