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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
=== tests/cases/compiler/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;
>getDomNode : () => any
destroy();
>destroy : () => any
gar(runner:(widget:Sample.Thing.IWidget)=>any):any;
>gar : (runner: (widget: IWidget) => any) => any
>runner : (widget: IWidget) => any
>widget : IWidget
>Sample : any
>Thing : any
}
export interface ICodeThing {
getDomNode(): Element;
>getDomNode : () => any
addWidget(widgetId:string, widget:IWidget);
>addWidget : (widgetId: string, widget: IWidget) => any
>widgetId : string
>widget : IWidget
focus();
>focus : () => any
//addWidget(widget: Sample.Thing.Widgets.IWidget);
}
export interface IAction {
run(Thing:ICodeThing):boolean;
>run : (Thing: ICodeThing) => boolean
>Thing : ICodeThing
getId():string;
>getId : () => string
}
}
module Sample.Actions.Thing.Find {
>Sample : typeof Sample
>Actions : typeof Actions
>Thing : typeof Thing
>Find : typeof Find
export class StartFindAction implements Sample.Thing.IAction {
>StartFindAction : StartFindAction
>Sample.Thing : typeof Sample.Thing
>Sample : typeof Sample
>Thing : typeof Sample.Thing
public getId() { return "yo"; }
>getId : () => string
>"yo" : "yo"
public run(Thing:Sample.Thing.ICodeThing):boolean {
>run : (Thing: Sample.Thing.ICodeThing) => boolean
>Thing : Sample.Thing.ICodeThing
>Sample : any
>Thing : any
return true;
>true : true
}
}
}
module Sample.Thing.Widgets {
>Sample : typeof Sample
>Thing : typeof Thing
>Widgets : typeof Widgets
export class FindWidget implements Sample.Thing.IWidget {
>FindWidget : FindWidget
>Sample.Thing : typeof Thing
>Sample : typeof Sample
>Thing : typeof Thing
public gar(runner:(widget:Sample.Thing.IWidget)=>any) { if (true) {return runner(this);}}
>gar : (runner: (widget: IWidget) => any) => any
>runner : (widget: IWidget) => any
>widget : IWidget
>Sample : any
>Thing : any
>true : true
>runner(this) : any
>runner : (widget: IWidget) => any
>this : this
private domNode:any = null;
>domNode : any
>null : null
constructor(private codeThing: Sample.Thing.ICodeThing) {
>codeThing : ICodeThing
>Sample : any
>Thing : any
// scenario 1
codeThing.addWidget("addWidget", this);
>codeThing.addWidget("addWidget", this) : any
>codeThing.addWidget : (widgetId: string, widget: IWidget) => any
>codeThing : ICodeThing
>addWidget : (widgetId: string, widget: IWidget) => any
>"addWidget" : "addWidget"
>this : this
}
public getDomNode() {
>getDomNode : () => any
return domNode;
>domNode : any
}
public destroy() {
>destroy : () => void
}
}
}
interface IMode { getInitialState(): IState;}
>getInitialState : () => IState
class AbstractMode implements IMode { public getInitialState(): IState { return null;} }
>AbstractMode : AbstractMode
>getInitialState : () => IState
>null : null
interface IState {}
interface Window {
opener: Window;
>opener : Window
}
declare var self: Window;
>self : Window
module Sample.Thing.Languages.PlainText {
>Sample : typeof Sample
>Thing : typeof Thing
>Languages : typeof Languages
>PlainText : typeof PlainText
export class State implements IState {
>State : State
constructor(private mode: IMode) { }
>mode : IMode
public clone():IState {
>clone : () => IState
return this;
>this : this
}
public equals(other:IState):boolean {
>equals : (other: IState) => boolean
>other : IState
return this === other;
>this === other : boolean
>this : this
>other : IState
}
public getMode(): IMode { return mode; }
>getMode : () => IMode
>mode : any
}
export class Mode extends AbstractMode {
>Mode : Mode
>AbstractMode : AbstractMode
// scenario 2
public getInitialState(): IState {
>getInitialState : () => IState
return new State(self);
>new State(self) : any
>State : typeof State
>self : Window
}
}
}
|