• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// @lib: es5
2// @sourcemap: true
3// Scenario 1: Test reqursive function call with "this" parameter
4// Scenario 2: Test recursive function call with cast and "this" parameter
5
6
7
8declare module Sample.Thing {
9
10	export interface IWidget {
11		getDomNode(): any;
12		destroy();
13		gar(runner:(widget:Sample.Thing.IWidget)=>any):any;
14	}
15
16	export interface ICodeThing {
17
18  		getDomNode(): Element;
19
20		addWidget(widgetId:string, widget:IWidget);
21
22
23		focus();
24
25		//addWidget(widget: Sample.Thing.Widgets.IWidget);
26	}
27
28	export interface IAction {
29		run(Thing:ICodeThing):boolean;
30		getId():string;
31	}
32}
33
34module Sample.Actions.Thing.Find {
35	export class StartFindAction implements Sample.Thing.IAction {
36
37		public getId() { return "yo"; }
38
39		public run(Thing:Sample.Thing.ICodeThing):boolean {
40
41			return true;
42		}
43	}
44}
45
46module Sample.Thing.Widgets {
47	export class FindWidget implements Sample.Thing.IWidget {
48
49		public gar(runner:(widget:Sample.Thing.IWidget)=>any) { if (true) {return runner(this);}}
50
51		private domNode:any = null;
52		constructor(private codeThing: Sample.Thing.ICodeThing) {
53		    // scenario 1
54		    codeThing.addWidget("addWidget", this);
55		}
56
57		public getDomNode() {
58			return domNode;
59		}
60
61		public destroy() {
62
63		}
64
65	}
66}
67
68interface IMode { getInitialState(): IState;}
69class AbstractMode implements IMode { public getInitialState(): IState { return null;} }
70
71interface IState {}
72
73interface Window {
74    opener: Window;
75}
76declare var self: Window;
77
78module Sample.Thing.Languages.PlainText {
79
80	export class State implements IState {
81        constructor(private mode: IMode) { }
82		public clone():IState {
83			return this;
84		}
85
86		public equals(other:IState):boolean {
87			return this === other;
88		}
89
90		public getMode(): IMode { return mode; }
91	}
92
93	export class Mode extends AbstractMode {
94
95		// scenario 2
96		public getInitialState(): IState {
97			return new State(self);
98		}
99
100
101	}
102}
103
104