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
|
tests/cases/compiler/recursiveClassReferenceTest.ts(16,19): error TS2304: Cannot find name 'Element'.
tests/cases/compiler/recursiveClassReferenceTest.ts(56,11): error TS2663: Cannot find name 'domNode'. Did you mean the instance member 'this.domNode'?
tests/cases/compiler/recursiveClassReferenceTest.ts(88,36): error TS2663: Cannot find name 'mode'. Did you mean the instance member 'this.mode'?
tests/cases/compiler/recursiveClassReferenceTest.ts(95,21): error TS2345: Argument of type 'Window' is not assignable to parameter of type 'IMode'.
Property 'getInitialState' is missing in type 'Window' but required in type 'IMode'.
==== tests/cases/compiler/recursiveClassReferenceTest.ts (4 errors) ====
// 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;
~~~~~~~
!!! error TS2304: Cannot find name '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;
~~~~~~~
!!! error TS2663: Cannot find name 'domNode'. Did you mean the instance member 'this.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; }
~~~~
!!! error TS2663: Cannot find name 'mode'. Did you mean the instance member 'this.mode'?
}
export class Mode extends AbstractMode {
// scenario 2
public getInitialState(): IState {
return new State(self);
~~~~
!!! error TS2345: Argument of type 'Window' is not assignable to parameter of type 'IMode'.
!!! error TS2345: Property 'getInitialState' is missing in type 'Window' but required in type 'IMode'.
!!! related TS2728 tests/cases/compiler/recursiveClassReferenceTest.ts:66:19: 'getInitialState' is declared here.
}
}
}
|