211 lines
5.8 KiB
JavaScript
211 lines
5.8 KiB
JavaScript
|
//// [recursiveClassReferenceTest.ts]
|
||
|
// Scenario 1: Test reqursive function call with "this" parameter
|
||
|
// Scenario 2: Test recursive function call with cast and "this" parameter
|
||
|
|
||
|
|
||
|
|
||
|
declare module Sample.Thing {
|
||
|
|
||
|
export interface IWidget {
|
||
|
getDomNode(): any;
|
||
|
destroy();
|
||
|
gar(runner:(widget:Sample.Thing.IWidget)=>any):any;
|
||
|
}
|
||
|
|
||
|
export interface ICodeThing {
|
||
|
|
||
|
getDomNode(): Element;
|
||
|
|
||
|
addWidget(widgetId:string, widget:IWidget);
|
||
|
|
||
|
|
||
|
focus();
|
||
|
|
||
|
//addWidget(widget: Sample.Thing.Widgets.IWidget);
|
||
|
}
|
||
|
|
||
|
export interface IAction {
|
||
|
run(Thing:ICodeThing):boolean;
|
||
|
getId():string;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module Sample.Actions.Thing.Find {
|
||
|
export class StartFindAction implements Sample.Thing.IAction {
|
||
|
|
||
|
public getId() { return "yo"; }
|
||
|
|
||
|
public run(Thing:Sample.Thing.ICodeThing):boolean {
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module Sample.Thing.Widgets {
|
||
|
export class FindWidget implements Sample.Thing.IWidget {
|
||
|
|
||
|
public gar(runner:(widget:Sample.Thing.IWidget)=>any) { if (true) {return runner(this);}}
|
||
|
|
||
|
private domNode:any = null;
|
||
|
constructor(private codeThing: Sample.Thing.ICodeThing) {
|
||
|
// scenario 1
|
||
|
codeThing.addWidget("addWidget", this);
|
||
|
}
|
||
|
|
||
|
public getDomNode() {
|
||
|
return domNode;
|
||
|
}
|
||
|
|
||
|
public destroy() {
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
interface IMode { getInitialState(): IState;}
|
||
|
class AbstractMode implements IMode { public getInitialState(): IState { return null;} }
|
||
|
|
||
|
interface IState {}
|
||
|
|
||
|
interface Window {
|
||
|
opener: Window;
|
||
|
}
|
||
|
declare var self: Window;
|
||
|
|
||
|
module Sample.Thing.Languages.PlainText {
|
||
|
|
||
|
export class State implements IState {
|
||
|
constructor(private mode: IMode) { }
|
||
|
public clone():IState {
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public equals(other:IState):boolean {
|
||
|
return this === other;
|
||
|
}
|
||
|
|
||
|
public getMode(): IMode { return mode; }
|
||
|
}
|
||
|
|
||
|
export class Mode extends AbstractMode {
|
||
|
|
||
|
// scenario 2
|
||
|
public getInitialState(): IState {
|
||
|
return new State(self);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
//// [recursiveClassReferenceTest.js]
|
||
|
var __extends = this.__extends || function (d, b) {
|
||
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||
|
function __() { this.constructor = d; }
|
||
|
__.prototype = b.prototype;
|
||
|
d.prototype = new __();
|
||
|
};
|
||
|
var Sample;
|
||
|
(function (Sample) {
|
||
|
(function (Actions) {
|
||
|
(function (Thing) {
|
||
|
(function (Find) {
|
||
|
var StartFindAction = (function () {
|
||
|
function StartFindAction() {
|
||
|
}
|
||
|
StartFindAction.prototype.getId = function () {
|
||
|
return "yo";
|
||
|
};
|
||
|
StartFindAction.prototype.run = function (Thing) {
|
||
|
return true;
|
||
|
};
|
||
|
return StartFindAction;
|
||
|
})();
|
||
|
Find.StartFindAction = StartFindAction;
|
||
|
})(Thing.Find || (Thing.Find = {}));
|
||
|
var Find = Thing.Find;
|
||
|
})(Actions.Thing || (Actions.Thing = {}));
|
||
|
var Thing = Actions.Thing;
|
||
|
})(Sample.Actions || (Sample.Actions = {}));
|
||
|
var Actions = Sample.Actions;
|
||
|
})(Sample || (Sample = {}));
|
||
|
var Sample;
|
||
|
(function (Sample) {
|
||
|
(function (Thing) {
|
||
|
(function (Widgets) {
|
||
|
var FindWidget = (function () {
|
||
|
function FindWidget(codeThing) {
|
||
|
this.codeThing = codeThing;
|
||
|
this.domNode = null;
|
||
|
codeThing.addWidget("addWidget", this);
|
||
|
}
|
||
|
FindWidget.prototype.gar = function (runner) {
|
||
|
if (true) {
|
||
|
return runner(this);
|
||
|
}
|
||
|
};
|
||
|
FindWidget.prototype.getDomNode = function () {
|
||
|
return domNode;
|
||
|
};
|
||
|
FindWidget.prototype.destroy = function () {
|
||
|
};
|
||
|
return FindWidget;
|
||
|
})();
|
||
|
Widgets.FindWidget = FindWidget;
|
||
|
})(Thing.Widgets || (Thing.Widgets = {}));
|
||
|
var Widgets = Thing.Widgets;
|
||
|
})(Sample.Thing || (Sample.Thing = {}));
|
||
|
var Thing = Sample.Thing;
|
||
|
})(Sample || (Sample = {}));
|
||
|
var AbstractMode = (function () {
|
||
|
function AbstractMode() {
|
||
|
}
|
||
|
AbstractMode.prototype.getInitialState = function () {
|
||
|
return null;
|
||
|
};
|
||
|
return AbstractMode;
|
||
|
})();
|
||
|
var Sample;
|
||
|
(function (Sample) {
|
||
|
(function (Thing) {
|
||
|
(function (Languages) {
|
||
|
(function (PlainText) {
|
||
|
var State = (function () {
|
||
|
function State(mode) {
|
||
|
this.mode = mode;
|
||
|
}
|
||
|
State.prototype.clone = function () {
|
||
|
return this;
|
||
|
};
|
||
|
State.prototype.equals = function (other) {
|
||
|
return this === other;
|
||
|
};
|
||
|
State.prototype.getMode = function () {
|
||
|
return mode;
|
||
|
};
|
||
|
return State;
|
||
|
})();
|
||
|
PlainText.State = State;
|
||
|
var Mode = (function (_super) {
|
||
|
__extends(Mode, _super);
|
||
|
function Mode() {
|
||
|
_super.apply(this, arguments);
|
||
|
}
|
||
|
Mode.prototype.getInitialState = function () {
|
||
|
return new State(self);
|
||
|
};
|
||
|
return Mode;
|
||
|
})(AbstractMode);
|
||
|
PlainText.Mode = Mode;
|
||
|
})(Languages.PlainText || (Languages.PlainText = {}));
|
||
|
var PlainText = Languages.PlainText;
|
||
|
})(Thing.Languages || (Thing.Languages = {}));
|
||
|
var Languages = Thing.Languages;
|
||
|
})(Sample.Thing || (Sample.Thing = {}));
|
||
|
var Thing = Sample.Thing;
|
||
|
})(Sample || (Sample = {}));
|
||
|
//# sourceMappingURL=recursiveClassReferenceTest.js.map
|