typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

Classes don't use type information from interface?

Open HomenSimpsor opened this issue 10 years ago • 3 comments

If an interface supplies type information, is the implementation required to repeat it?

Class:

image

image

Interface:

image

image

Additionally, the description isn't loaded in (just says inheritdoc as if there's nothing in the implementation to show).

If I keep all the types except the return value, the description shows again:

image

image

HomenSimpsor avatar Dec 15 '15 03:12 HomenSimpsor

Perhaps this issue would be more clearly named, "Add support the @inheritdoc tag, a la JSDoc".

mattflix avatar Jan 26 '16 07:01 mattflix

+1

I need this feature desperately as well. Important to mention that it is not only related to interface -> class inheritance, but also to interface -> interface and class -> class.

I haven't managed to implement this feature in my fork. It looks like TypePlugin doesn't resolve overwrites type for fields and methods very well, or does it after ImplementsPlugin processing. Only constructors are resolved properly.

enepomnyaschih avatar Apr 23 '16 07:04 enepomnyaschih

TypeDoc's behavior is consistent with TypeScript's, yes, the implementing class must repeat type information from the interface.

interface Interface {
  method(a: string, b: number): void
}

class Class implements Interface {
  method(a, b) {
    b.substring(1, 2) // but wait, a is the string! TS doesn't know since the parameters aren't typed.
  }
}

Gerrit0 avatar Dec 30 '19 04:12 Gerrit0