1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
// @lib: es5
// @sourcemap: true
// 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);
}
}
}
|