Search code examples
inheritancecoffeescriptsuperparse-error

using super by defining class-inheritance in coffeescript gives me parse error when compiling


I am trying to define a class inherited from another base-class in coffeescript and I am getting parse-error when compiling. Exyctly : Parse error on line 6: Unexpected ',' My code looks like :

class MedVisGraphNode
constructor : (@nodeId, @nodeLabel) ->

class MedVisGenericContainerNode extends MedVisGraphNode
constructor : (groupId, groupLabel, @groupType, @outerGroupNode) ->
    super (groupId, groupLabel)

# method which determines if the actual group-node group lies in an another or sist on top of the hierarchy
isOnTopOfHierarchy = () ->
    return @outerGroupNode == 'undefined'

The weird thing is when I try to compile a similar code taken from the web here :

class Animal
constructor : (@species, @isMammal=false) ->

class Dog extends Animal
constructor : (@name) ->
    super ("canine",true)

toString : ->
    "#{@name} is a #{@species}."

I am getting the same parse-error. I am very confused now, because i am not able to find what is going wrong, could please someone give me a small hint ?


Solution

  • Either don't use parentheses, or make sure there's no whitespace between it and super:

    super 'canine', true
    // or
    super('canine', true)