Skip to content

Commit 6e06752

Browse files
Merge pull request #5972 from reavowed/master
Limit error reporting for methods to the method name
2 parents ecfeb21 + 46f1a2c commit 6e06752

19 files changed

+36
-42
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ namespace ts {
342342
case SyntaxKind.EnumMember:
343343
case SyntaxKind.FunctionDeclaration:
344344
case SyntaxKind.FunctionExpression:
345+
case SyntaxKind.MethodDeclaration:
345346
errorNode = (<Declaration>node).name;
346347
break;
347348
}

tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class.
22
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1244: Abstract methods can only appear within an abstract class.
3-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
3+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,14): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
44

55

66
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts (3 errors) ====
@@ -14,6 +14,6 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
1414
abstract foo() {}
1515
~~~~~~~~
1616
!!! error TS1244: Abstract methods can only appear within an abstract class.
17-
~~~~~~~~~~~~~~~~~
17+
~~~
1818
!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
1919
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
1+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,14): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
22

33

44
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ====
55
abstract class A {
66
abstract foo() {}
7-
~~~~~~~~~~~~~~~~~
7+
~~~
88
!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
99
}

tests/baselines/reference/computedPropertyNames40_ES5.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(9,
1414
[""]() { return new Foo }
1515
~~~~
1616
!!! error TS2393: Duplicate function implementation.
17-
~~~~~~~~~~~~~~~~~~~~~~~~~
17+
~~~~
1818
!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'.
1919
[""]() { return new Foo2 }
2020
~~~~

tests/baselines/reference/computedPropertyNames40_ES6.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(9,
1414
[""]() { return new Foo }
1515
~~~~
1616
!!! error TS2393: Duplicate function implementation.
17-
~~~~~~~~~~~~~~~~~~~~~~~~~
17+
~~~~
1818
!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'.
1919
[""]() { return new Foo2 }
2020
~~~~
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
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.
21
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator body.
2+
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.
33

44

55
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts (2 errors) ====
66
function* g() {
77
class C {
88
@(yield "")
9-
~~~~~~~~~~~
109
~~~~~
1110
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
1211
m() { }
13-
~~~~~~~~~~~~~~~
12+
~
1413
!!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.
1514
};
1615
}

tests/baselines/reference/implicitAnyAmbients.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ tests/cases/compiler/implicitAnyAmbients.ts(23,13): error TS7005: Variable 'y' i
3939

4040
class C {
4141
foo(); // error
42-
~~~~~~
42+
~~~
4343
!!! error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type.
4444
foo2(x: any); // error
45-
~~~~~~~~~~~~~
45+
~~~~
4646
!!! error TS7010: 'foo2', which lacks return-type annotation, implicitly has an 'any' return type.
4747
foo3(x: any): any;
4848
}

tests/baselines/reference/implicitAnyFunctionReturnNullOrUndefined.errors.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,16 @@ tests/cases/compiler/implicitAnyFunctionReturnNullOrUndefined.ts(10,5): error TS
1515

1616
class C {
1717
nullWidenFuncOfC() { // error at "nullWidenFuncOfC"
18-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18+
~~~~~~~~~~~~~~~~
19+
!!! error TS7010: 'nullWidenFuncOfC', which lacks return-type annotation, implicitly has an 'any' return type.
1920
return null;
20-
~~~~~~~~~~~~~~~~~~~~
2121
}
22-
~~~~~
23-
!!! error TS7010: 'nullWidenFuncOfC', which lacks return-type annotation, implicitly has an 'any' return type.
2422

2523
underfinedWidenFuncOfC() { // error at "underfinedWidenFuncOfC"
26-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
~~~~~~~~~~~~~~~~~~~~~~
25+
!!! error TS7010: 'underfinedWidenFuncOfC', which lacks return-type annotation, implicitly has an 'any' return type.
2726
return undefined;
28-
~~~~~~~~~~~~~~~~~~~~~~~~~
2927
}
30-
~~~~~
31-
!!! error TS7010: 'underfinedWidenFuncOfC', which lacks return-type annotation, implicitly has an 'any' return type.
3228
}
3329

3430
// this should not be an error

tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(3,9): error TS7008: Member 'publicMember' implicitly has an 'any' type.
2-
tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,9): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type.
2+
tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,16): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type.
33
tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,31): error TS7006: Parameter 'x' implicitly has an 'any' type.
44
tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(8,9): error TS1089: 'private' modifier cannot appear on a constructor declaration.
55

@@ -13,7 +13,7 @@ tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(8,9): error TS1089: 'pri
1313
private privateMember; // this should not be an error
1414

1515
public publicFunction(x); // this should be an error
16-
~~~~~~~~~~~~~~~~~~~~~~~~~
16+
~~~~~~~~~~~~~~
1717
!!! error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type.
1818
~
1919
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.

tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(1,18): error TS7010:
22
tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(1,22): error TS7006: Parameter 'x' implicitly has an 'any' type.
33
tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(2,13): error TS7005: Variable 'bar' implicitly has an 'any' type.
44
tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(4,5): error TS7008: Member 'publicMember' implicitly has an 'any' type.
5-
tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,5): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type.
5+
tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,12): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type.
66
tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,27): error TS7006: Parameter 'x' implicitly has an 'any' type.
77
tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(9,5): error TS1089: 'private' modifier cannot appear on a constructor declaration.
88
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:
2424
private privateMember; // this should not be an error
2525

2626
public publicFunction(x); // this should be an error
27-
~~~~~~~~~~~~~~~~~~~~~~~~~
27+
~~~~~~~~~~~~~~
2828
!!! error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type.
2929
~
3030
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.

0 commit comments

Comments
 (0)