jashkenas/coffeescript

Proposal: allow super in object literals

Open

#5,075 opened on May 23, 2018

View on GitHub
 (13 comments) (0 reactions) (0 assignees)CoffeeScript (1,980 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (16,577 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Contributor guide