typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

Type member incorrectly shown as `any`

Open srmagura opened this issue 2 years ago • 5 comments

Search terms

any

Expected Behavior

TypeDoc should not show the email member as having type any for the following code:

export type Validators = {
  email: (value: string) => boolean;
};

Actual Behavior

image

Steps to reproduce the bug

  1. Clone https://github.com/srmagura/typedoc-namespace-variable-repro.
  2. yarn install
  3. yarn typedoc

Environment

  • Typedoc version: 0.22.8
  • TypeScript version: 4.4.4
  • Node.js version: 16.13.0
  • OS: Windows 11

srmagura avatar Nov 11 '21 03:11 srmagura

Wow, that's a weird one... should be an easy fix at least, looks like it's just a rendering issue.

Gerrit0 avatar Nov 13 '21 02:11 Gerrit0

@Gerrit0 Is this issue been worked on by anyone? I could give it a try and raise a PR. Any initial pointers or fix you might have thought of?

aqumus avatar Nov 23 '21 23:11 aqumus

Not as far as I know - type.tsx is going to be the file you want.

Gerrit0 avatar Nov 24 '21 04:11 Gerrit0

I've searched in the code and the type.tsx file is not handling function parameters here:

https://github.com/TypeStrong/typedoc/blob/3f0dbeab09ec61b5351f6766a0b13f37ea26c8c7/src/lib/output/themes/default/partials/type.tsx#L335

The item.type is undefined, and that's why any appears. But item if it's a function has signatures and each signature has parameters that are not rendered there.

https://github.com/TypeStrong/typedoc/blob/3f0dbeab09ec61b5351f6766a0b13f37ea26c8c7/src/lib/output/themes/default/partials/member.signature.title.tsx#L25

Here instead is where the parameters and signatures are handled.

It's not simple for a new contributor to handle this change, I managed the parameters, but I can't find the function return value

matteobruni avatar Dec 10 '21 10:12 matteobruni

Ah, shoot... yeah, that mostly makes sense now... I've never liked ReflectionTypes which is what is responsible for this. Probably going to be an annoying one to fix.

Gerrit0 avatar Jan 08 '22 19:01 Gerrit0