diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c1910fa9e05..1fa9151d500 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2659,7 +2659,7 @@ "Raise error on 'this' expressions with an implied 'any' type.": { "category": "Message", "code": 6115 - } + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols index 4b312fd4646..06999513192 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols @@ -10,9 +10,9 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9)) ->other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt index 8cf85d4f764..d3597ad2507 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts(10,19): error TS2352: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts(10,19): error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. Property 'a' is missing in type '{ m(): this is Foo; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredic !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. let dis = this as Foo; ~~~~~~~~~~~ -!!! error TS2352: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +!!! error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. !!! error TS2352: Property 'a' is missing in type '{ m(): this is Foo; }'. return dis.a != null && dis.b != null && dis.c != null; } diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt index 0c0661023f5..7a4716a92e0 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(8,14): error TS4025: Exported variable 'obj' has or is using private name 'Foo'. tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(10,19): error TS2352: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(10,19): error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. Property 'a' is missing in type '{ m(): this is Foo; }'. @@ -20,7 +20,7 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredic !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. let dis = this as Foo; ~~~~~~~~~~~ -!!! error TS2352: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +!!! error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. !!! error TS2352: Property 'a' is missing in type '{ m(): this is Foo; }'. return dis.a != null && dis.b != null && dis.c != null; } diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index 4531797586c..69e9493b24a 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'C'. 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 TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. @@ -51,7 +51,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I ~~~~~ -!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. let u: Unused; let y = u.implicitNoThis; n = y(12); // ok, callee:void matches this:any diff --git a/tests/baselines/reference/noImplicitThisFunctions.errors.txt b/tests/baselines/reference/noImplicitThisFunctions.errors.txt index c80552c6b37..5f66ac3553f 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.errors.txt +++ b/tests/baselines/reference/noImplicitThisFunctions.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. -tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. ==== tests/cases/compiler/noImplicitThisFunctions.ts (2 errors) ==== @@ -18,11 +18,11 @@ tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2682: 'this' imp // error: this is implicitly any return this.a + z; ~~~~ -!!! error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. } // error: `this` is `window`, but is still of type `any` let f4: (b: number) => number = b => this.c + b; ~~~~ -!!! error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 3c25b31e0a8..41711b526c7 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(39,21): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(56,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(59,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(61,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. @@ -13,10 +13,10 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2683: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. Types of property 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2683: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -73,11 +73,11 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,1): er Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(148,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2681: A setter cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2679: A 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2681: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2682: A setter cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2681: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,26): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,30): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,20): error TS2370: A rest parameter must be of an array type. @@ -154,11 +154,11 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -196,13 +196,13 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. wrongPropertyType.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. -!!! error TS2683: Types of property 'y' are incompatible. -!!! error TS2683: Type 'string' is not assignable to type 'number'. +!!! error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2684: Types of property 'y' are incompatible. +!!! error TS2684: Type 'string' is not assignable to type 'number'. wrongPropertyName.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. -!!! error TS2683: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +!!! error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2684: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. let c = new C(); c.explicitC(); // not enough arguments @@ -371,27 +371,27 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e } let voidThis = new VoidThis(); ~~~~~~~~~~~~~~ -!!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +!!! error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is void. ///// syntax-ish errors ///// class ThisConstructor { constructor(this: ThisConstructor, private n: number) { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2680: A constructor cannot have a 'this' parameter. +!!! error TS2681: A constructor cannot have a 'this' parameter. } set p(this: void) { ~~~~~~~~~~ -!!! error TS2681: A setter cannot have a 'this' parameter. +!!! error TS2682: A setter cannot have a 'this' parameter. } } interface ThisConstructorInterface { new(this: ThisConstructor, n: number); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2680: A constructor cannot have a 'this' parameter. +!!! error TS2681: A constructor cannot have a 'this' parameter. } function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ -!!! error TS2679: A 'this' parameter must be the first parameter. +!!! error TS2680: A 'this' parameter must be the first parameter. ///// parse errors ///// function modifiers(async this: C): number { return this.n; }