From e22863238a4948d1d3ff086a187b9455aecee083 Mon Sep 17 00:00:00 2001 From: Iain Monro Date: Mon, 7 Dec 2015 17:37:27 +0000 Subject: [PATCH 1/2] Limit error reporting for methods to the method name --- src/compiler/checker.ts | 2 +- src/compiler/utilities.ts | 1 + ...ssAbstractMethodInNonAbstractClass.errors.txt | 4 ++-- ...ssAbstractMethodWithImplementation.errors.txt | 4 ++-- .../computedPropertyNames40_ES5.errors.txt | 2 +- .../computedPropertyNames40_ES6.errors.txt | 2 +- .../reference/generatorTypeCheck59.errors.txt | 5 ++--- .../reference/implicitAnyAmbients.errors.txt | 4 ++-- ...itAnyFunctionReturnNullOrUndefined.errors.txt | 16 ++++++---------- .../implicitAnyInAmbientDeclaration.errors.txt | 4 ++-- ...implicitAnyInAmbientDeclaration2.d.errors.txt | 4 ++-- .../noImplicitAnyForMethodParameters.errors.txt | 4 ++-- .../reference/noImplicitAnyModule.errors.txt | 4 ++-- ...adOnConstNoNonSpecializedSignature.errors.txt | 2 +- .../reference/parserParameterList16.errors.txt | 2 +- ...otSubtypeOfNonSpecializedSignature.errors.txt | 6 +++--- ...exerConstrainsPropertyDeclarations.errors.txt | 8 +++----- ...ralTypesInImplementationSignatures.errors.txt | 4 ++-- ...alTypesInImplementationSignatures2.errors.txt | 6 +++--- .../typeCheckObjectLiteralMethodBody.errors.txt | 2 +- 20 files changed, 40 insertions(+), 46 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 30d4818592b..7b48e8b2016 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11175,7 +11175,7 @@ namespace ts { // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. if (node.flags & NodeFlags.Abstract && node.body) { - error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); + error(node.body, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 95bf4ff7fa3..f955db2d0c2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -342,6 +342,7 @@ namespace ts { case SyntaxKind.EnumMember: case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: + case SyntaxKind.MethodDeclaration: errorNode = (node).name; break; } diff --git a/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt index d6f9b7540d4..25842a1840a 100644 --- a/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt +++ b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1244: Abstract methods can only appear within an abstract class. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,20): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts (3 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract foo() {} ~~~~~~~~ !!! error TS1244: Abstract methods can only appear within an abstract class. - ~~~~~~~~~~~~~~~~~ + ~~ !!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt index 412378e267d..abaeef7c750 100644 --- a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,20): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== abstract class A { abstract foo() {} - ~~~~~~~~~~~~~~~~~ + ~~ !!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt index 482978064d1..40a9e9a2e3d 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(9, [""]() { return new Foo } ~~~~ !!! error TS2393: Duplicate function implementation. - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'. [""]() { return new Foo2 } ~~~~ diff --git a/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt index 669d0d04e66..10c0a456dbe 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(9, [""]() { return new Foo } ~~~~ !!! error TS2393: Duplicate function implementation. - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'. [""]() { return new Foo2 } ~~~~ diff --git a/tests/baselines/reference/generatorTypeCheck59.errors.txt b/tests/baselines/reference/generatorTypeCheck59.errors.txt index d8d532a430a..d8179803821 100644 --- a/tests/baselines/reference/generatorTypeCheck59.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck59.errors.txt @@ -1,16 +1,15 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(3,9): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator body. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(4,9): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts (2 errors) ==== function* g() { class C { @(yield "") - ~~~~~~~~~~~ ~~~~~ !!! error TS1163: A 'yield' expression is only allowed in a generator body. m() { } - ~~~~~~~~~~~~~~~ + ~ !!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. }; } \ No newline at end of file diff --git a/tests/baselines/reference/implicitAnyAmbients.errors.txt b/tests/baselines/reference/implicitAnyAmbients.errors.txt index e71fd6f72ea..d425edbfefd 100644 --- a/tests/baselines/reference/implicitAnyAmbients.errors.txt +++ b/tests/baselines/reference/implicitAnyAmbients.errors.txt @@ -39,10 +39,10 @@ tests/cases/compiler/implicitAnyAmbients.ts(23,13): error TS7005: Variable 'y' i class C { foo(); // error - ~~~~~~ + ~~~ !!! error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type. foo2(x: any); // error - ~~~~~~~~~~~~~ + ~~~~ !!! error TS7010: 'foo2', which lacks return-type annotation, implicitly has an 'any' return type. foo3(x: any): any; } diff --git a/tests/baselines/reference/implicitAnyFunctionReturnNullOrUndefined.errors.txt b/tests/baselines/reference/implicitAnyFunctionReturnNullOrUndefined.errors.txt index 9ad1c550d72..40803016ae8 100644 --- a/tests/baselines/reference/implicitAnyFunctionReturnNullOrUndefined.errors.txt +++ b/tests/baselines/reference/implicitAnyFunctionReturnNullOrUndefined.errors.txt @@ -15,20 +15,16 @@ tests/cases/compiler/implicitAnyFunctionReturnNullOrUndefined.ts(10,5): error TS class C { nullWidenFuncOfC() { // error at "nullWidenFuncOfC" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - return null; - ~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS7010: 'nullWidenFuncOfC', which lacks return-type annotation, implicitly has an 'any' return type. + return null; + } underfinedWidenFuncOfC() { // error at "underfinedWidenFuncOfC" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - return undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS7010: 'underfinedWidenFuncOfC', which lacks return-type annotation, implicitly has an 'any' return type. + return undefined; + } } // this should not be an error diff --git a/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt b/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt index 4775ec0511b..1e66f26d0d2 100644 --- a/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt +++ b/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(3,9): error TS7008: Member 'publicMember' implicitly has an 'any' type. -tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,9): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. +tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,16): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,31): error TS7006: Parameter 'x' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(8,9): error TS1089: 'private' modifier cannot appear on a constructor declaration. @@ -13,7 +13,7 @@ tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(8,9): error TS1089: 'pri private privateMember; // this should not be an error public publicFunction(x); // this should be an error - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. diff --git a/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt b/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt index 11f2ae90d35..54fe39e2efe 100644 --- a/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt +++ b/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(1,18): error TS7010: tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(1,22): error TS7006: Parameter 'x' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(2,13): error TS7005: Variable 'bar' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(4,5): error TS7008: Member 'publicMember' implicitly has an 'any' type. -tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,5): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. +tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,12): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,27): error TS7006: Parameter 'x' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(9,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(13,24): error TS7006: Parameter 'publicConsParam' implicitly has an 'any' type. @@ -24,7 +24,7 @@ tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(13,24): error TS7006: private privateMember; // this should not be an error public publicFunction(x); // this should be an error - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. diff --git a/tests/baselines/reference/noImplicitAnyForMethodParameters.errors.txt b/tests/baselines/reference/noImplicitAnyForMethodParameters.errors.txt index 176f40f16f3..07782d86e9e 100644 --- a/tests/baselines/reference/noImplicitAnyForMethodParameters.errors.txt +++ b/tests/baselines/reference/noImplicitAnyForMethodParameters.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noImplicitAnyForMethodParameters.ts(6,5): error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type. +tests/cases/compiler/noImplicitAnyForMethodParameters.ts(6,12): error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/noImplicitAnyForMethodParameters.ts(6,16): error TS7006: Parameter 'a' implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyForMethodParameters.ts(10,17): error TS7006: Parameter 'a' implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyForMethodParameters.ts(13,16): error TS7006: Parameter 'a' implicitly has an 'any' type. @@ -11,7 +11,7 @@ tests/cases/compiler/noImplicitAnyForMethodParameters.ts(13,16): error TS7006: P declare class B { public foo(a); // OK - ambient class and public method - error - ~~~~~~~~~~~~~~ + ~~~ !!! error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type. ~ !!! error TS7006: Parameter 'a' implicitly has an 'any' type. diff --git a/tests/baselines/reference/noImplicitAnyModule.errors.txt b/tests/baselines/reference/noImplicitAnyModule.errors.txt index cb2dfbe5793..35c0993df3e 100644 --- a/tests/baselines/reference/noImplicitAnyModule.errors.txt +++ b/tests/baselines/reference/noImplicitAnyModule.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/noImplicitAnyModule.ts(5,9): error TS7013: Construct signature, which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/noImplicitAnyModule.ts(10,18): error TS7006: Parameter 'x' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyModule.ts(11,9): error TS7010: 'g', which lacks return-type annotation, implicitly has an 'any' return type. +tests/cases/compiler/noImplicitAnyModule.ts(11,16): error TS7010: 'g', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/noImplicitAnyModule.ts(18,14): error TS7010: 'f', which lacks return-type annotation, implicitly has an 'any' return type. @@ -20,7 +20,7 @@ tests/cases/compiler/noImplicitAnyModule.ts(18,14): error TS7010: 'f', which lac ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. public g(x: any); - ~~~~~~~~~~~~~~~~~ + ~ !!! error TS7010: 'g', which lacks return-type annotation, implicitly has an 'any' return type. // Should not return error at all. diff --git a/tests/baselines/reference/overloadOnConstNoNonSpecializedSignature.errors.txt b/tests/baselines/reference/overloadOnConstNoNonSpecializedSignature.errors.txt index f897cae121d..6b96abce29e 100644 --- a/tests/baselines/reference/overloadOnConstNoNonSpecializedSignature.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoNonSpecializedSignature.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/overloadOnConstNoNonSpecializedSignature.ts(2,4): error TS2 ==== tests/cases/compiler/overloadOnConstNoNonSpecializedSignature.ts (1 errors) ==== class C { x1(a: 'hi'); // error, no non-specialized signature in overload list - ~~~~~~~~~~~~ + ~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. x1(a: string) { } } diff --git a/tests/baselines/reference/parserParameterList16.errors.txt b/tests/baselines/reference/parserParameterList16.errors.txt index f4de32b0f91..4b30b386e6f 100644 --- a/tests/baselines/reference/parserParameterList16.errors.txt +++ b/tests/baselines/reference/parserParameterList16.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16. ==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16.ts (2 errors) ==== class C { foo(a = 4); - ~~~~~~~~~~~ + ~~~ !!! error TS2394: Overload signature is not compatible with function implementation. ~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. diff --git a/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt b/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt index 6b705a0c34d..a9293a83a13 100644 --- a/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt +++ b/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt @@ -23,7 +23,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignat class C { foo(x: 'a'); - ~~~~~~~~~~~~ + ~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. foo(x: number); foo(x: any) { } @@ -31,7 +31,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignat class C2 { foo(x: 'a'); - ~~~~~~~~~~~~ + ~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. foo(x: T); foo(x: any) { } @@ -39,7 +39,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignat class C3 { foo(x: 'a'); - ~~~~~~~~~~~~ + ~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. foo(x: T); foo(x: any) { } diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index 1f4ee3debed..08881be2a86 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -75,12 +75,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. foo() { // error - ~~~~~~~~~~~~~~~~ - return ''; - ~~~~~~~~~~~~~~~~~~ - } - ~~~~~ + ~~~ !!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. + return ''; + } static sa: number; // ok static sb: string; // ok diff --git a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.errors.txt b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.errors.txt index b89553fcf5b..2bff320197a 100644 --- a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.errors.txt @@ -26,7 +26,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType class C { foo(x: 'hi') { } - ~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2381: A signature with an implementation cannot use a string literal type. } @@ -50,7 +50,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType var b = { foo(x: 'hi') { }, - ~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2381: A signature with an implementation cannot use a string literal type. a: function foo(x: 'hi', y: 'hi') { }, ~~~ diff --git a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.errors.txt b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.errors.txt index 8d296e68a17..4f94bad7441 100644 --- a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.errors.txt @@ -25,7 +25,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType class C { foo(x: string); foo(x: 'hi') { } - ~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2381: A signature with an implementation cannot use a string literal type. } @@ -63,12 +63,12 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType foo(x: 'hi') { }, ~~~ !!! error TS2300: Duplicate identifier 'foo'. - ~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2381: A signature with an implementation cannot use a string literal type. foo(x: 'a') { }, ~~~ !!! error TS2300: Duplicate identifier 'foo'. - ~~~~~~~~~~~~~~~ + ~~~ !!! error TS2381: A signature with an implementation cannot use a string literal type. } \ No newline at end of file diff --git a/tests/baselines/reference/typeCheckObjectLiteralMethodBody.errors.txt b/tests/baselines/reference/typeCheckObjectLiteralMethodBody.errors.txt index 7db4c2506cc..5c4a9236e01 100644 --- a/tests/baselines/reference/typeCheckObjectLiteralMethodBody.errors.txt +++ b/tests/baselines/reference/typeCheckObjectLiteralMethodBody.errors.txt @@ -3,5 +3,5 @@ tests/cases/compiler/typeCheckObjectLiteralMethodBody.ts(1,13): error TS7010: 'b ==== tests/cases/compiler/typeCheckObjectLiteralMethodBody.ts (1 errors) ==== var foo = { bar() { return undefined } }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~ !!! error TS7010: 'bar', which lacks return-type annotation, implicitly has an 'any' return type. \ No newline at end of file From 46f1a2cc5dcdb6c9062bc7fd9c67dd3cff6c7a28 Mon Sep 17 00:00:00 2001 From: Iain Monro Date: Tue, 8 Dec 2015 12:25:45 +0000 Subject: [PATCH 2/2] Revert change to abstract-method-with-body error location --- src/compiler/checker.ts | 2 +- .../classAbstractMethodInNonAbstractClass.errors.txt | 4 ++-- .../classAbstractMethodWithImplementation.errors.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7b48e8b2016..30d4818592b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11175,7 +11175,7 @@ namespace ts { // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. if (node.flags & NodeFlags.Abstract && node.body) { - error(node.body, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); + error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } } diff --git a/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt index 25842a1840a..48968c2b585 100644 --- a/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt +++ b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1244: Abstract methods can only appear within an abstract class. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,20): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,14): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts (3 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract foo() {} ~~~~~~~~ !!! error TS1244: Abstract methods can only appear within an abstract class. - ~~ + ~~~ !!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt index abaeef7c750..0917b1f50b4 100644 --- a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,20): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,14): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== abstract class A { abstract foo() {} - ~~ + ~~~ !!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. } \ No newline at end of file