Skip to content

Unexpected warning when implementing an interface without @extends #3137

Closed
@rictic

Description

@rictic

The following code:

/** @interface */
class FooInterface {
  /** @return {string} */
  foo() {};
}


/**
 * @implements {FooInterface}
 */
class Foo {
  /** @return {string} */
  foo() {
    return '';
  }
}

Produces the warning:

 WARNING - property foo already defined on interface FooInterface; use @override to override it
  foo() {
  ^^^^^^^

The documentation at https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#override seems to suggest that this shouldn't be necessary:

[The @override tag] is not required when a class extends a superclass or implements an interface

This is with the internal flag set RECOMMENDED_FLAGS. I didn't see a way to repro it on the closure compiler service. Googlers can see cl/220008730 internally, or repro with

  blaze build //experimental/users/rictic/override-implement-interface:bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions