jashkenas/coffeescript

Proposal: allow super in object literals

Open

#5075 aperta il 23 mag 2018

Vedi su GitHub
 (13 commenti) (0 reazioni) (0 assegnatari)CoffeeScript (1980 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (16.577 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

As seen on MDN.

obj1 = ->
  method1: ->
    console.log 'method1'

obj2 =
  method2: ->
    super.method1()

Object.setPrototypeOf obj2, obj1
obj2.method2() # logs "method1"

The obj2 variable would transpile to:

obj2 = {
  method2() {
    super.method1();
  }
};

Guida contributor