Accept new baselines

This commit is contained in:
Anders Hejlsberg 2017-02-28 16:11:05 -08:00
parent 25738a8e41
commit f77cd8e54b
37 changed files with 346 additions and 226 deletions

View file

@ -71,13 +71,7 @@ var p_cast = <Point> ({
return new Point(this.x + dx, this.y + dy);
>Point : Symbol(Point, Decl(castTest.ts, 11, 37))
>this.x : Symbol(Point.x, Decl(castTest.ts, 14, 1))
>this : Symbol(Point, Decl(castTest.ts, 11, 37))
>x : Symbol(Point.x, Decl(castTest.ts, 14, 1))
>dx : Symbol(dx, Decl(castTest.ts, 25, 18))
>this.y : Symbol(Point.y, Decl(castTest.ts, 15, 14))
>this : Symbol(Point, Decl(castTest.ts, 11, 37))
>y : Symbol(Point.y, Decl(castTest.ts, 15, 14))
>dy : Symbol(dy, Decl(castTest.ts, 25, 21))
},

View file

@ -91,15 +91,15 @@ var p_cast = <Point> ({
return new Point(this.x + dx, this.y + dy);
>new Point(this.x + dx, this.y + dy) : Point
>Point : typeof Point
>this.x + dx : number
>this.x : number
>this : Point
>x : number
>this.x + dx : any
>this.x : any
>this : any
>x : any
>dx : number
>this.y + dy : number
>this.y : number
>this : Point
>y : number
>this.y + dy : any
>this.y : any
>this : any
>y : any
>dy : number
},

View file

@ -21,10 +21,6 @@ var v = {
>a : Symbol(a, Decl(commentsOnObjectLiteral3.ts, 8, 13), Decl(commentsOnObjectLiteral3.ts, 12, 18))
return this.prop;
>this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9))
>this : Symbol(v, Decl(commentsOnObjectLiteral3.ts, 1, 7))
>prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9))
} /*trailing 1*/,
//setter
set a(value) {
@ -32,9 +28,6 @@ var v = {
>value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7))
this.prop = value;
>this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9))
>this : Symbol(v, Decl(commentsOnObjectLiteral3.ts, 1, 7))
>prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9))
>value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7))
} // trailing 2

View file

@ -1,8 +1,8 @@
=== tests/cases/compiler/commentsOnObjectLiteral3.ts ===
var v = {
>v : { prop: number; func: () => void; func1(): void; a: number; }
>{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1(): void; a: number; }
>v : { prop: number; func: () => void; func1(): void; a: any; }
>{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1(): void; a: any; }
//property
prop: 1 /* multiple trailing comments */ /*trailing comments*/,
@ -21,25 +21,25 @@ var v = {
//getter
get a() {
>a : number
>a : any
return this.prop;
>this.prop : number
>this : { prop: number; func: () => void; func1(): void; a: number; }
>prop : number
>this.prop : any
>this : any
>prop : any
} /*trailing 1*/,
//setter
set a(value) {
>a : number
>value : number
>a : any
>value : any
this.prop = value;
>this.prop = value : number
>this.prop : number
>this : { prop: number; func: () => void; func1(): void; a: number; }
>prop : number
>value : number
>this.prop = value : any
>this.prop : any
>this : any
>prop : any
>value : any
} // trailing 2
};

View file

@ -15,9 +15,6 @@ function /*1*/makePoint(x: number) {
set x(a: number) { this.b = a; }
>x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30))
>a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14))
>this.b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12))
>this : Symbol(__object, Decl(declFileObjectLiteralWithAccessors.ts, 2, 10))
>b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12))
>a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14))
};

View file

@ -19,9 +19,9 @@ function /*1*/makePoint(x: number) {
>x : number
>a : number
>this.b = a : number
>this.b : number
>this : { b: number; x: number; }
>b : number
>this.b : any
>this : any
>b : any
>a : number
};

View file

@ -11,9 +11,6 @@ function /*1*/makePoint(x: number) {
set x(a: number) { this.b = a; }
>x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 3, 14))
>a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14))
>this.b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12))
>this : Symbol(__object, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 10))
>b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12))
>a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14))
};

View file

@ -15,9 +15,9 @@ function /*1*/makePoint(x: number) {
>x : number
>a : number
>this.b = a : number
>this.b : number
>this : { b: number; x: number; }
>b : number
>this.b : any
>this : any
>b : any
>a : number
};

View file

@ -8,18 +8,11 @@ var object = {
get 0() {
return this._0;
>this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14))
>this : Symbol(object, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12))
>_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14))
},
set 0(x: number) {
>x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10))
this._0 = x;
>this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14))
>this : Symbol(object, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12))
>_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14))
>x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10))
},

View file

@ -10,9 +10,9 @@ var object = {
get 0() {
return this._0;
>this._0 : number
>this : { _0: number; 0: number; }
>_0 : number
>this._0 : any
>this : any
>_0 : any
},
set 0(x: number) {
@ -20,9 +20,9 @@ var object = {
this._0 = x;
>this._0 = x : number
>this._0 : number
>this : { _0: number; 0: number; }
>_0 : number
>this._0 : any
>this : any
>_0 : any
>x : number
},

View file

@ -163,11 +163,6 @@ var messenger = {
setTimeout(() => { this.message.toString(); }, 3000);
>setTimeout : Symbol(setTimeout, Decl(fatarrowfunctions.ts, 34, 1))
>this.message.toString : Symbol(String.toString, Decl(lib.d.ts, --, --))
>this.message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17))
>this : Symbol(messenger, Decl(fatarrowfunctions.ts, 38, 15))
>message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17))
>toString : Symbol(String.toString, Decl(lib.d.ts, --, --))
}
};

View file

@ -234,12 +234,12 @@ var messenger = {
>setTimeout(() => { this.message.toString(); }, 3000) : number
>setTimeout : (expression: any, msec?: number, language?: any) => number
>() => { this.message.toString(); } : () => void
>this.message.toString() : string
>this.message.toString : () => string
>this.message : string
>this : { message: string; start: () => void; }
>message : string
>toString : () => string
>this.message.toString() : any
>this.message.toString : any
>this.message : any
>this : any
>message : any
>toString : any
>3000 : 3000
}
};

View file

@ -16,17 +16,12 @@ var messenger = {
var _self = this;
>_self : Symbol(_self, Decl(fatarrowfunctionsInFunctions.ts, 5, 11))
>this : Symbol(messenger, Decl(fatarrowfunctionsInFunctions.ts, 2, 15))
setTimeout(function() {
>setTimeout : Symbol(setTimeout, Decl(fatarrowfunctionsInFunctions.ts, 0, 0))
_self.message.toString();
>_self.message.toString : Symbol(String.toString, Decl(lib.d.ts, --, --))
>_self.message : Symbol(message, Decl(fatarrowfunctionsInFunctions.ts, 2, 17))
>_self : Symbol(_self, Decl(fatarrowfunctionsInFunctions.ts, 5, 11))
>message : Symbol(message, Decl(fatarrowfunctionsInFunctions.ts, 2, 17))
>toString : Symbol(String.toString, Decl(lib.d.ts, --, --))
}, 3000);
}

View file

@ -18,8 +18,8 @@ var messenger = {
>function() { var _self = this; setTimeout(function() { _self.message.toString(); }, 3000); } : () => void
var _self = this;
>_self : { message: string; start: () => void; }
>this : { message: string; start: () => void; }
>_self : any
>this : any
setTimeout(function() {
>setTimeout(function() { _self.message.toString(); }, 3000) : number
@ -27,12 +27,12 @@ var messenger = {
>function() { _self.message.toString(); } : () => void
_self.message.toString();
>_self.message.toString() : string
>_self.message.toString : () => string
>_self.message : string
>_self : { message: string; start: () => void; }
>message : string
>toString : () => string
>_self.message.toString() : any
>_self.message.toString : any
>_self.message : any
>_self : any
>message : any
>toString : any
}, 3000);
>3000 : 3000

View file

@ -1,13 +1,14 @@
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(22,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'.
The 'this' types of each signature are incompatible.
Type 'void' is not assignable to type 'C'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(25,27): error TS2339: Property 'length' does not exist on type 'number'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(26,27): error TS2339: Property 'length' does not exist on type 'number'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(34,28): error TS2339: Property 'length' does not exist on type 'number'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(38,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'.
tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(47,20): error TS2339: Property 'length' does not exist on type 'number'.
==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (5 errors) ====
interface I {
n: number;
explicitThis(this: this, m: number): number;

View file

@ -1,4 +1,5 @@
//// [looseThisTypeInFunctions.ts]
interface I {
n: number;
explicitThis(this: this, m: number): number;

View file

@ -200,9 +200,6 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }
>plus : Symbol(plus, Decl(objectSpread.ts, 49, 23))
>c : Symbol(c, Decl(objectSpread.ts, 45, 3))
>plus : Symbol(plus, Decl(objectSpread.ts, 49, 48))
>this.p : Symbol(p, Decl(objectSpread.ts, 49, 12))
>this : Symbol(cplus, Decl(objectSpread.ts, 49, 10))
>p : Symbol(p, Decl(objectSpread.ts, 49, 12))
cplus.plus();
>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23))

View file

@ -263,13 +263,13 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }
>cplus : { p: number; plus(): void; }
>p : number
>plus : () => void
>{ ...c, plus() { return this.p + 1; } } : { plus(): number; p: number; }
>{ ...c, plus() { return this.p + 1; } } : { plus(): any; p: number; }
>c : C
>plus : () => number
>this.p + 1 : number
>this.p : number
>this : { p: number; plus(): void; }
>p : number
>plus : () => any
>this.p + 1 : any
>this.p : any
>this : any
>p : any
>1 : 1
cplus.plus();

View file

@ -1,4 +1,5 @@
//// [selfInLambdas.ts]
interface MouseEvent {
x: number;
y: number;

View file

@ -1,51 +1,52 @@
=== tests/cases/compiler/selfInLambdas.ts ===
interface MouseEvent {
>MouseEvent : Symbol(MouseEvent, Decl(selfInLambdas.ts, 0, 0))
x: number;
>x : Symbol(MouseEvent.x, Decl(selfInLambdas.ts, 0, 22))
>x : Symbol(MouseEvent.x, Decl(selfInLambdas.ts, 1, 22))
y: number;
>y : Symbol(MouseEvent.y, Decl(selfInLambdas.ts, 1, 14))
>y : Symbol(MouseEvent.y, Decl(selfInLambdas.ts, 2, 14))
}
declare var window: Window;
>window : Symbol(window, Decl(selfInLambdas.ts, 5, 11))
>Window : Symbol(Window, Decl(selfInLambdas.ts, 5, 27))
>window : Symbol(window, Decl(selfInLambdas.ts, 6, 11))
>Window : Symbol(Window, Decl(selfInLambdas.ts, 6, 27))
interface Window {
>Window : Symbol(Window, Decl(selfInLambdas.ts, 5, 27))
>Window : Symbol(Window, Decl(selfInLambdas.ts, 6, 27))
onmousemove: (ev: MouseEvent) => any;
>onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 6, 18))
>ev : Symbol(ev, Decl(selfInLambdas.ts, 7, 18))
>onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 7, 18))
>ev : Symbol(ev, Decl(selfInLambdas.ts, 8, 18))
>MouseEvent : Symbol(MouseEvent, Decl(selfInLambdas.ts, 0, 0))
}
var o = {
>o : Symbol(o, Decl(selfInLambdas.ts, 10, 3))
>o : Symbol(o, Decl(selfInLambdas.ts, 11, 3))
counter: 0,
>counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9))
>counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9))
start: function() {
>start : Symbol(start, Decl(selfInLambdas.ts, 12, 15))
>start : Symbol(start, Decl(selfInLambdas.ts, 13, 15))
window.onmousemove = () => {
>window.onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 6, 18))
>window : Symbol(window, Decl(selfInLambdas.ts, 5, 11))
>onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 6, 18))
>window.onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 7, 18))
>window : Symbol(window, Decl(selfInLambdas.ts, 6, 11))
>onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 7, 18))
this.counter++
>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9))
>this : Symbol(o, Decl(selfInLambdas.ts, 10, 7))
>counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9))
>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9))
>this : Symbol(o, Decl(selfInLambdas.ts, 11, 7))
>counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9))
var f = () => this.counter;
>f : Symbol(f, Decl(selfInLambdas.ts, 18, 15))
>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9))
>this : Symbol(o, Decl(selfInLambdas.ts, 10, 7))
>counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9))
>f : Symbol(f, Decl(selfInLambdas.ts, 19, 15))
>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9))
>this : Symbol(o, Decl(selfInLambdas.ts, 11, 7))
>counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9))
}
@ -56,39 +57,39 @@ var o = {
class X {
>X : Symbol(X, Decl(selfInLambdas.ts, 24, 1))
>X : Symbol(X, Decl(selfInLambdas.ts, 25, 1))
private value = "value";
>value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9))
>value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9))
public foo() {
>foo : Symbol(X.foo, Decl(selfInLambdas.ts, 29, 25))
>foo : Symbol(X.foo, Decl(selfInLambdas.ts, 30, 25))
var outer= () => {
>outer : Symbol(outer, Decl(selfInLambdas.ts, 32, 5))
>outer : Symbol(outer, Decl(selfInLambdas.ts, 33, 5))
var x = this.value;
>x : Symbol(x, Decl(selfInLambdas.ts, 33, 15))
>this.value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9))
>this : Symbol(X, Decl(selfInLambdas.ts, 24, 1))
>value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9))
>x : Symbol(x, Decl(selfInLambdas.ts, 34, 15))
>this.value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9))
>this : Symbol(X, Decl(selfInLambdas.ts, 25, 1))
>value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9))
var inner = () => {
>inner : Symbol(inner, Decl(selfInLambdas.ts, 34, 15))
>inner : Symbol(inner, Decl(selfInLambdas.ts, 35, 15))
var y = this.value;
>y : Symbol(y, Decl(selfInLambdas.ts, 35, 19))
>this.value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9))
>this : Symbol(X, Decl(selfInLambdas.ts, 24, 1))
>value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9))
>y : Symbol(y, Decl(selfInLambdas.ts, 36, 19))
>this.value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9))
>this : Symbol(X, Decl(selfInLambdas.ts, 25, 1))
>value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9))
}
inner();
>inner : Symbol(inner, Decl(selfInLambdas.ts, 34, 15))
>inner : Symbol(inner, Decl(selfInLambdas.ts, 35, 15))
};
outer();
>outer : Symbol(outer, Decl(selfInLambdas.ts, 32, 5))
>outer : Symbol(outer, Decl(selfInLambdas.ts, 33, 5))
}
}

View file

@ -1,4 +1,5 @@
=== tests/cases/compiler/selfInLambdas.ts ===
interface MouseEvent {
>MouseEvent : MouseEvent

View file

@ -0,0 +1,28 @@
tests/cases/compiler/thisBinding2.ts(11,11): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
==== tests/cases/compiler/thisBinding2.ts (1 errors) ====
class C {
x: number;
constructor() {
this.x = (() => {
var x = 1;
return this.x;
})();
this.x = function() {
var x = 1;
return this.x;
~~~~
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
}();
}
}
declare function setTimeout(expression: any, msec?: number, language?: any): number;
var messenger = {
message: "Hello World",
start: function () {
return setTimeout(() => { var x = this.message; }, 3000);
}
};

View file

@ -1,4 +1,5 @@
//// [thisBinding2.ts]
class C {
x: number;
constructor() {

View file

@ -1,25 +0,0 @@
tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(15,21): error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'.
==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (1 errors) ====
class MyClass {
t: number;
fn() {
type ContainingThis = this;
//type of 'this' in an object literal is the containing scope's this
var t = { x: this, y: this.t };
var t: { x: ContainingThis; y: number };
}
}
//type of 'this' in an object literal method is the type of the object literal
var obj = {
f() {
return this.spaaace;
~~~~~~~
!!! error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'.
}
};
var obj: { f: () => any; };

View file

@ -0,0 +1,45 @@
=== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts ===
class MyClass {
>MyClass : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0))
t: number;
>t : Symbol(MyClass.t, Decl(thisInObjectLiterals.ts, 0, 15))
fn() {
>fn : Symbol(MyClass.fn, Decl(thisInObjectLiterals.ts, 1, 14))
type ContainingThis = this;
>ContainingThis : Symbol(ContainingThis, Decl(thisInObjectLiterals.ts, 3, 10))
//type of 'this' in an object literal is the containing scope's this
var t = { x: this, y: this.t };
>t : Symbol(t, Decl(thisInObjectLiterals.ts, 6, 11), Decl(thisInObjectLiterals.ts, 7, 11))
>x : Symbol(x, Decl(thisInObjectLiterals.ts, 6, 17))
>this : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0))
>y : Symbol(y, Decl(thisInObjectLiterals.ts, 6, 26))
>this.t : Symbol(MyClass.t, Decl(thisInObjectLiterals.ts, 0, 15))
>this : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0))
>t : Symbol(MyClass.t, Decl(thisInObjectLiterals.ts, 0, 15))
var t: { x: ContainingThis; y: number };
>t : Symbol(t, Decl(thisInObjectLiterals.ts, 6, 11), Decl(thisInObjectLiterals.ts, 7, 11))
>x : Symbol(x, Decl(thisInObjectLiterals.ts, 7, 16))
>ContainingThis : Symbol(ContainingThis, Decl(thisInObjectLiterals.ts, 3, 10))
>y : Symbol(y, Decl(thisInObjectLiterals.ts, 7, 35))
}
}
//type of 'this' in an object literal method is the type of the object literal
var obj = {
>obj : Symbol(obj, Decl(thisInObjectLiterals.ts, 12, 3), Decl(thisInObjectLiterals.ts, 17, 3))
f() {
>f : Symbol(f, Decl(thisInObjectLiterals.ts, 12, 11))
return this.spaaace;
}
};
var obj: { f: () => any; };
>obj : Symbol(obj, Decl(thisInObjectLiterals.ts, 12, 3), Decl(thisInObjectLiterals.ts, 17, 3))
>f : Symbol(f, Decl(thisInObjectLiterals.ts, 17, 10))

View file

@ -0,0 +1,50 @@
=== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts ===
class MyClass {
>MyClass : MyClass
t: number;
>t : number
fn() {
>fn : () => void
type ContainingThis = this;
>ContainingThis : this
//type of 'this' in an object literal is the containing scope's this
var t = { x: this, y: this.t };
>t : { x: this; y: number; }
>{ x: this, y: this.t } : { x: this; y: number; }
>x : this
>this : this
>y : number
>this.t : number
>this : this
>t : number
var t: { x: ContainingThis; y: number };
>t : { x: this; y: number; }
>x : this
>ContainingThis : this
>y : number
}
}
//type of 'this' in an object literal method is the type of the object literal
var obj = {
>obj : { f(): any; }
>{ f() { return this.spaaace; }} : { f(): any; }
f() {
>f : () => any
return this.spaaace;
>this.spaaace : any
>this : any
>spaaace : any
}
};
var obj: { f: () => any; };
>obj : { f(): any; }
>f : () => any

View file

@ -70,7 +70,6 @@ class A {
a: function() { return this; },
>a : Symbol(a, Decl(thisInPropertyBoundDeclarations.ts, 33, 13))
>this : Symbol(__object, Decl(thisInPropertyBoundDeclarations.ts, 33, 11))
};
@ -80,7 +79,6 @@ class A {
return {
a: function() { return this; },
>a : Symbol(a, Decl(thisInPropertyBoundDeclarations.ts, 38, 16))
>this : Symbol(__object, Decl(thisInPropertyBoundDeclarations.ts, 38, 14))
};
};

View file

@ -84,9 +84,9 @@ class A {
>{ a: function() { return this; }, } : { a: () => any; }
a: function() { return this; },
>a : () => { a: any; }
>function() { return this; } : () => { a: any; }
>this : { a: () => any; }
>a : () => any
>function() { return this; } : () => any
>this : any
};
@ -98,9 +98,9 @@ class A {
>{ a: function() { return this; }, } : { a: () => any; }
a: function() { return this; },
>a : () => { a: any; }
>function() { return this; } : () => { a: any; }
>this : { a: () => any; }
>a : () => any
>function() { return this; } : () => any
>this : any
};
};

View file

@ -0,0 +1,60 @@
tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts(15,5): error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type.
==== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts (1 errors) ====
interface IndexedWithThis {
// this is a workaround for React
init?: (this: this) => void;
willDestroy?: (this: any) => void;
[propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any);
}
interface IndexedWithoutThis {
// this is what React would like to write (and what they write today)
init?: () => void;
willDestroy?: () => void;
[propName: string]: any;
}
interface SimpleInterface {
foo(n: string);
~~~~~~~~~~~~~~~
!!! error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type.
bar(): number;
}
declare function extend1(args: IndexedWithThis): void;
declare function extend2(args: IndexedWithoutThis): void;
declare function simple(arg: SimpleInterface): void;
extend1({
init() {
this // this: IndexedWithThis because of contextual typing.
// this.mine
this.willDestroy
},
mine: 12,
foo() {
this.url; // this: any because 'foo' matches the string indexer
this.willDestroy;
}
});
extend2({
init() {
this // this: containing object literal type
this.mine
},
mine: 13,
foo() {
this // this: containing object literal type
this.mine
}
});
simple({
foo(n) {
return n.length + this.bar();
},
bar() {
return 14;
}
})

View file

@ -1,4 +1,5 @@
//// [thisTypeInFunctions2.ts]
interface IndexedWithThis {
// this is a workaround for React
init?: (this: this) => void;

View file

@ -1,4 +1,5 @@
//// [thisTypeInObjectLiterals.ts]
let o = {
d: "bar",
m() {

View file

@ -1,104 +1,105 @@
=== tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts ===
let o = {
>o : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 3))
>o : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 1, 3))
d: "bar",
>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9))
>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9))
m() {
>m : Symbol(m, Decl(thisTypeInObjectLiterals.ts, 1, 13))
>m : Symbol(m, Decl(thisTypeInObjectLiterals.ts, 2, 13))
return this.d.length;
>this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9))
>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 7))
>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9))
>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9))
>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 1, 7))
>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
},
f: function() {
>f : Symbol(f, Decl(thisTypeInObjectLiterals.ts, 4, 6))
>f : Symbol(f, Decl(thisTypeInObjectLiterals.ts, 5, 6))
return this.d.length;
>this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9))
>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 7))
>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9))
>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9))
>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 1, 7))
>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
}
}
let mutuallyRecursive = {
>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3))
>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 3))
a: 100,
>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25))
>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 11, 25))
start() {
>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11))
>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 12, 11))
return this.passthrough(this.a);
>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23))
>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6))
>this.a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23))
>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25))
>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23))
>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6))
>this.a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 11, 25))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23))
>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 11, 25))
},
passthrough(n: number) {
>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16))
>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 16, 16))
return this.sub1(n);
>this.sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23))
>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16))
>this.sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 18, 6))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23))
>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 18, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 16, 16))
},
sub1(n: number): number {
>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9))
>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 18, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9))
if (n > 0) {
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9))
return this.passthrough(n - 1);
>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23))
>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9))
>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6))
>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23))
>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9))
}
return n;
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9))
}
}
var i: number = mutuallyRecursive.start();
>i : Symbol(i, Decl(thisTypeInObjectLiterals.ts, 25, 3))
>mutuallyRecursive.start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11))
>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3))
>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11))
>i : Symbol(i, Decl(thisTypeInObjectLiterals.ts, 26, 3))
>mutuallyRecursive.start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 12, 11))
>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 3))
>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 12, 11))
interface I {
>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 25, 42))
>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 26, 42))
a: number;
>a : Symbol(I.a, Decl(thisTypeInObjectLiterals.ts, 26, 13))
>a : Symbol(I.a, Decl(thisTypeInObjectLiterals.ts, 27, 13))
start(): number;
>start : Symbol(I.start, Decl(thisTypeInObjectLiterals.ts, 27, 14))
>start : Symbol(I.start, Decl(thisTypeInObjectLiterals.ts, 28, 14))
passthrough(n: number): number;
>passthrough : Symbol(I.passthrough, Decl(thisTypeInObjectLiterals.ts, 28, 20))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 29, 16))
>passthrough : Symbol(I.passthrough, Decl(thisTypeInObjectLiterals.ts, 29, 20))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 30, 16))
sub1(n: number): number;
>sub1 : Symbol(I.sub1, Decl(thisTypeInObjectLiterals.ts, 29, 35))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 30, 9))
>sub1 : Symbol(I.sub1, Decl(thisTypeInObjectLiterals.ts, 30, 35))
>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 31, 9))
}
var impl: I = mutuallyRecursive;
>impl : Symbol(impl, Decl(thisTypeInObjectLiterals.ts, 32, 3))
>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 25, 42))
>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3))
>impl : Symbol(impl, Decl(thisTypeInObjectLiterals.ts, 33, 3))
>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 26, 42))
>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 3))

View file

@ -1,4 +1,5 @@
=== tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts ===
let o = {
>o : { d: string; m(): number; f: () => number; }
>{ d: "bar", m() { return this.d.length; }, f: function() { return this.d.length; }} : { d: string; m(): number; f: () => number; }

View file

@ -89,7 +89,6 @@ var aa = {
>biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 41, 10))
throw this;
>this : Symbol(aa, Decl(throwInEnclosingStatements.ts, 40, 8))
}
}

View file

@ -104,7 +104,7 @@ var aa = {
>biz : () => void
throw this;
>this : { id: number; biz(): void; }
>this : any
}
}

View file

@ -395,16 +395,10 @@ var buttonView = {
onClick: function () { alert('clicked: ' + this.label); },
>onClick : Symbol(onClick, Decl(underscoreTest1_underscoreTests.ts, 97, 24))
>alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14))
>this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18))
>this : Symbol(buttonView, Decl(underscoreTest1_underscoreTests.ts, 96, 16))
>label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18))
onHover: function () { alert('hovering: ' + this.label); }
>onHover : Symbol(onHover, Decl(underscoreTest1_underscoreTests.ts, 98, 62))
>alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14))
>this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18))
>this : Symbol(buttonView, Decl(underscoreTest1_underscoreTests.ts, 96, 16))
>label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18))
};
_.bindAll(buttonView);

View file

@ -827,9 +827,9 @@ var buttonView = {
>alert : (x: string) => void
>'clicked: ' + this.label : string
>'clicked: ' : "clicked: "
>this.label : string
>this : { label: string; onClick: () => void; onHover: () => void; }
>label : string
>this.label : any
>this : any
>label : any
onHover: function () { alert('hovering: ' + this.label); }
>onHover : () => void
@ -838,9 +838,9 @@ var buttonView = {
>alert : (x: string) => void
>'hovering: ' + this.label : string
>'hovering: ' : "hovering: "
>this.label : string
>this : { label: string; onClick: () => void; onHover: () => void; }
>label : string
>this.label : any
>this : any
>label : any
};
_.bindAll(buttonView);