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

Derived class should't re-define inherited members #125

Closed
aidinabedi opened this issue Apr 6, 2020 · 0 comments · Fixed by #126
Closed

Derived class should't re-define inherited members #125

aidinabedi opened this issue Apr 6, 2020 · 0 comments · Fixed by #126

Comments

@aidinabedi
Copy link
Contributor

Currently, if a class extends another, all base members will be re-defined in the extended class. So the following JS code:

/**
 *
 */
class BaseClass {
    /**
     *
     */
    baseFunc() {}
    /**
     *
     */
    baseFuncOverridden() {}
}

/**
 * @extends BaseClass
 */
class DerivedClass extends BaseClass {
    /**
     *
     */
    derivedFunc() {}
    /**
     *
     */
    baseFuncOverridden() {}
}

Will result in the following typescript code

declare class BaseClass {
    baseFunc(): void;
    baseFuncOverridden(): void;
}

declare class DerivedClass extends BaseClass {
    derivedFunc(): void;
    baseFuncOverridden(): void;
    baseFunc(): void; // <-- REDFINED BASE CLASS MEMBER
}

Althought this might seem fine, it can actually causes issues in multiple cases. Such as if the derived class is private, because then tsd-jsdoc tries to re-define public base members in a private derived class, which results in the following:

[TSD-JSDoc] Failed to find parent of doclet 'baseFunc' using memberof 'DerivedClass', this is likely due to invalid JSDoc.
[TSD-JSDoc] Failed to find parent of doclet 'baseFuncOverridden' using memberof 'DerivedClass', this is likely due to invalid JSDoc.

And when you have many such cases the log is filled with warnings that shouldn't be there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant