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

noImplicitOverride doesn't work if member is defined in multiple interfaces #45345

Closed
frigus02 opened this issue Aug 6, 2021 · 0 comments · Fixed by #45352
Closed

noImplicitOverride doesn't work if member is defined in multiple interfaces #45345

frigus02 opened this issue Aug 6, 2021 · 0 comments · Fixed by #45352
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@frigus02
Copy link
Contributor

frigus02 commented Aug 6, 2021

Bug Report

The --noImplicitOverride check doesn't catch the case where an overridden member is defined in multiple interfaces.

We found this in code using Polymer. Compiling the following example with tsc file.ts --target esnext --moduleResolution node --noImplicitOverride gives the inlined error. But I would have expected the error as well for connectedCallback.

class XCustom extends PolymerElement {
    connectedCallback() { super.connectedCallback(); }
    disconnectedCallback() {  super.disconnectedCallback();  }
 // ~~~~~~~~~~~~~~~~~~~~ This member must have an 'override' modifier because it overrides a member in the base class 'PolymerElement'.
}

I boiled it down to the minimal example below.

🔎 Search Terms

noImplicitOverride, override, interface, multiple

🕗 Version & Regression Information

This is the behavior in every version I tried: 4.3.5, 4.4.0-beta

⏯ Playground Link

Playground link with relevant code

💻 Code

const ElementMixin: ElementMixinConstructor & PropertiesMixinConstructor = class {
  connectedCallback() {}
  disconnectedCallback() {}
};

interface ElementMixinConstructor {
  new(...args: any[]): ElementMixin;
}

interface ElementMixin {
  connectedCallback(): void;
}

interface PropertiesMixinConstructor {
  new(...args: any[]): PropertiesMixin;
}

interface PropertiesMixin {
  connectedCallback(): void;
  disconnectedCallback(): void;
}

export class TestElement extends ElementMixin {
  connectedCallback() {
    super.connectedCallback();
  }

  disconnectedCallback() {
    super.disconnectedCallback();
  }
}

🙁 Actual behavior

Compiled with --noImplicitOverride, this only requires override for disconnectedCallback but not for connectedCallback.

As soon as I remove connectedCallback from either the ElementMixin or PropertiesMixin interface, TypeScript requires override for it as well.

The behavior is the same for property members.

🙂 Expected behavior

I would expect TypeScript to require override for both disconnectedCallback and connectedCallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
4 participants