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

Return type of some functions is incorrect. #571

Closed
tomc974 opened this issue Jul 28, 2017 · 5 comments
Closed

Return type of some functions is incorrect. #571

tomc974 opened this issue Jul 28, 2017 · 5 comments
Labels
bug Functionality does not match expectation

Comments

@tomc974
Copy link

tomc974 commented Jul 28, 2017

Hi!

I have a function with a logic similar to the below function

function f(x: number) {
  if (x < 5) return true
  if (x > 20) return false
  return undefined
}
  • The return type inferred by the TypeScript compiler is boolean | undefined
  • The return type produced by TypeDoc is undefined | true | false

No big deal but still annoying...

@aciccarello
Copy link
Collaborator

aciccarello commented Jul 28, 2017

@tomc974, I'm curious, why would you want a true | false type rather than a boolean type? In my mind those are the same with the possible exception of allowing null.

@tomc974
Copy link
Author

tomc974 commented Jul 28, 2017

@aciccarello It's the other way around. I do want the boolean | undefined type but TypeDoc generates documentation with undefined | true | false. Try to run it on the provided example ;-)

@aciccarello
Copy link
Collaborator

@tomc974 Sorry, I misunderstood.

I've confirmed TypeDoc is outputting differently than TypeScript's implicit definition. If the function is explicitly given a boolean | undefined return type, that is respected by TypeDoc.

image
image

@aciccarello aciccarello added the bug Functionality does not match expectation label Jul 28, 2017
@calebsander
Copy link

I see this with an interface method that has the signature writeValue(buffer: GrowableBuffer, value: VALUE, root?: boolean): void. The type for root shows up instead as root?: undefined | true | false. I have an abstract class that implements this interface with an abstract version of the method. Interestingly, it is also broken for the abstract class, but subclasses of the abstract class that implement this method have the correct documentation.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 27, 2020

Fixed in 0.20.0 beta 30

@Gerrit0 Gerrit0 moved this from To do to Done in Version 0.20 Dec 27, 2020
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
Projects
No open projects
Development

No branches or pull requests

4 participants