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

Hiding all overloads also hides the main function #2122

Closed
asportnoy opened this issue Dec 12, 2022 · 4 comments
Closed

Hiding all overloads also hides the main function #2122

asportnoy opened this issue Dec 12, 2022 · 4 comments
Labels
bug Functionality does not match expectation needs reproduction Needs a minimal reproducible case - https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05d

Comments

@asportnoy
Copy link

Search terms

@hidden, overload

Expected Behavior

#1142 adds the ability to apply @hidden to only some overloads without hiding all of them. I'd expect that I can apply @hidden to all of the overloads except for the original function and still be able to see the original, non-overloaded function.

Actual Behavior

Typedoc hides the function when all the overloads are hidden

Steps to reproduce the bug

MRE: https://tsplay.dev/w1An8w
Notice how all overloads are marked with @hidden, but the original function is not. Typedoc hides this entire function from the docs, when I'd expect it to still show the combined method.

Environment

  • Typedoc version: 0.23.22
  • TypeScript version: 4.8.4
  • Node.js version: 16.17.1
  • OS: macOS Ventura
@asportnoy asportnoy added the bug Functionality does not match expectation label Dec 12, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 13, 2022

I can't seem to reproduce this. I pasted your file into a basic project, ran typedoc, and got this output:

image

I suspect your code was actually:

/** @hidden */
function getSomething(all: true): string[];
/** @hidden */
function getSomething(all: false): string;

function getSomething(all: boolean): string | string[] {
 return []
}

This is different. When overloads are declared, the signature declared on the implementation is not visible outside of the function, and effectively does not exist (getSomething(Math.random() > 0.5) is a type error). If you want the catch-all signature to be visible, you need to add it separately

/** @hidden */
function getSomething(all: true): string[];
/** @hidden */
function getSomething(all: false): string;
/** documented! */
function getSomething(all: boolean): string | string[];
function getSomething(all: boolean): string | string[] {
 return []
}

@Gerrit0 Gerrit0 added the needs reproduction Needs a minimal reproducible case - https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05d label Dec 13, 2022
@asportnoy
Copy link
Author

The declare isn't in my actual code, I just did it there so I wouldn't have to define the actual function for the example. Wasn't aware it would make a difference.

@asportnoy
Copy link
Author

I think I tried adding the combined overload but it caused type errors. Will try again later and let you know.

@asportnoy
Copy link
Author

Must've messed something up the first time, it works now. Thanks!

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 needs reproduction Needs a minimal reproducible case - https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05d
Projects
None yet
Development

No branches or pull requests

2 participants