Documentation of interfaces lacks examples of ES6 syntax

Open Beginner friendly
#4,039 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript
Domain
documentation

Research direction

Start with the linked Types in the Closure Type System wiki page and the Structural Interfaces chapter, especially the nominal interfaces section. Add a concise ES6 class-syntax example showing an interface and an implementing class, based on the example in the issue. Done means the relevant interface documentation includes a clear, accurate ES6 or ESNext usage example.

Written by the indexing model from the issue text.

Description

ES6 or ESNext is very popular nowadays, it would be nice to add some examples to the documentation of interfaces on how to use them with ES6 class syntax.

The documentation of interfaces can be found roughly here:

  1. all types
  2. special chapter

Somewhere in there, it would be nice to have a usage example along the lines of:

/**
 * @interface
 */
class ISerializable {
  constructor() {
    /** @type {string} */
    this.id;
  }
  
  /**
   * @returns {string}
   */
  serialize() {}
}

/**
 * @implements {ISerializable}
 */
class Car {
  constructor() {
    this.id = 'FJS904328JS';
  }

  serialize() {
    return '{ "id": "FJS904328JS"}'
  }
}
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 21h
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/closure-compiler

All issues in google/closure-compiler

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.