Syntax
With the JSDoc tag dictionary (enabled by default):
@interface [<name>]
With the Closure Compiler tag dictionary:
@interface
Overview
The @interface
tag marks a symbol as an interface that other symbols can implement. For example,
your code might define a parent class whose methods and properties are stubbed out. You can add the
@interface
tag to the parent class to indicate that child classes must implement the parent class'
methods and properties.
Add the @interface
tag to the top-level symbol for the interface (for example, a constructor
function). You do not need to add the @interface
tag to each member of the interface (for example,
the interface's instance methods).
If you are using the JSDoc tag dictionary (enabled by default), you can also define an interface with virtual comments, rather than by writing code for the interface. See "Virtual comments that define an interface" for an example.
Examples
In the following example, the Color
function represents an interface that other classes can
implement:
The following example uses virtual comments, rather than code, to define the Color
interface: