jashkenas/coffeescript

Proposal: allow super in object literals

Open

#5,075 建立於 2018年5月23日

在 GitHub 查看
 (13 留言) (0 反應) (0 負責人)CoffeeScript (16,577 star) (1,980 fork)batch import
enhancementhelp wanted

描述

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();
  }
};

貢獻者指南