Open jorgebg opened 11 years ago
EDIT : I remembered this not working but apparently it does
Yes it works in CoffeeScript :(
Can you log the myapp object and check out what's up with it - what its prototype is, etc.?
Isn't it because we don't actually return the parent constructor ? Other typed thingies
Yes it is, If I return the parent constructor it works:
Express = require 'express'
class MyApp extends Express
-> return super ...
myapp = new MyApp
myapp.listen 3000
But when I try to extend it without overriding the constructor in order to return the parent constructor, the TypeError
appears again:
class MyApp2 extends MyApp
myapp2 = new MyApp2
myapp2.listen 3000
TypeError: Object #<MyApp2> has no method 'listen'
at Object.<anonymous> (/tmp/myapp2.ls:19:8)
...
Some logging:
Express = require 'express'
class MyApp extends Express
console.log MyApp # Too long, pasted here http://pastebin.com/fwM33jXP
myapp = new MyApp
cosole.log myapp # It returns an empty object {}
The following code works in
CoffeeScript
:According to CoffeeScript to LiveScript Conversion Guide, the following code should work in
LiveScript
, but it throws the following error:Why? And how can it be solved? Thanks!
PD: In case you doubt about what
express
is, it is the well-known web application framework for node :) and here is the link: http://expressjs.com/