Created
July 11, 2016 23:41
-
-
Save zbjornson/2053cf1a30e893f38f7910dcada712d2 to your computer and use it in GitHub Desktop.
(SO question) JS for typescript, trying to create generic factory method on base class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var MyNS; | |
(function (MyNS) { | |
var Base = (function () { | |
function Base() { | |
} | |
Base.create = function (foo) { | |
return new MyNS[foo.type](); | |
}; | |
return Base; | |
}()); | |
MyNS.Base = Base; | |
})(MyNS = exports.MyNS || (exports.MyNS = {})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var __extends = (this && this.__extends) || function (d, b) { | |
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | |
function __() { this.constructor = d; } | |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
}; | |
/// <reference path="Base.ts" /> | |
var MyNS; | |
(function (MyNS) { | |
var Descendant = (function (_super) { | |
__extends(Descendant, _super); | |
function Descendant() { | |
_super.apply(this, arguments); | |
} | |
Descendant.prototype.echo = function (s) { | |
return s; | |
}; | |
return Descendant; | |
}(MyNS.Base)); | |
MyNS.Descendant = Descendant; | |
})(MyNS = exports.MyNS || (exports.MyNS = {})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment