Closed friendofasquid closed 12 years ago
Hi,
Everything worked as expected, there must be something wrong with your code.
Take a look at this example, maybe it can help you.
friendofasquid
|-- app.js
|-- src
| `-- foo
| |-- bar.coffee
| `-- foo.coffee
`-- toaster.coffee
#<< foo/foo
class Bar extends foo.Foo
constructor:->
console.log "NEW BAR!"
new foo.Foo()
new foo.Bar()
class Foo
constructor:->
console.log "NEW FOO!"
var __t;
__t = function(ns) {
var curr, index, part, parts, _i, _len;
curr = null;
parts = [].concat = ns.split(".");
for (index = _i = 0, _len = parts.length; _i < _len; index = ++_i) {
part = parts[index];
if (curr === null) {
curr = eval(part);
continue;
} else {
if (curr[part] == null) {
curr = curr[part] = {};
} else {
curr = curr[part];
}
}
}
return curr;
};
var foo = {};
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
__t('foo').Foo = (function() {
function Foo() {
console.log("NEW FOO!");
}
return Foo;
})();
__t('foo').Bar = (function(_super) {
__extends(Bar, _super);
function Bar() {
console.log("NEW BAR!");
new foo.Foo();
}
return Bar;
})(foo.Foo);
new foo.Bar();
}).call(this);
$ node app.js
NEW BAR!
NEW FOO!
Seems like if I have a file in a folder dist/foo
and then , in the same folder
then Bar isn't available in the foo namespace (e.g. foo.Bar) but Foo is (foo.Foo). If I remove the extends from Bar, it is available.