Skip to content

Commit 6e06752

Browse files
Merge pull request microsoft#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.

tests/baselines/reference/noImplicitAnyForMethodParameters.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/compiler/noImplicitAnyForMethodParameters.ts(6,5): error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type.
1+
tests/cases/compiler/noImplicitAnyForMethodParameters.ts(6,12): error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type.
22
tests/cases/compiler/noImplicitAnyForMethodParameters.ts(6,16): error TS7006: Parameter 'a' implicitly has an 'any' type.
33
tests/cases/compiler/noImplicitAnyForMethodParameters.ts(10,17): error TS7006: Parameter 'a' implicitly has an 'any' type.
44
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
1111

1212
declare class B {
1313
public foo(a); // OK - ambient class and public method - error
14-
~~~~~~~~~~~~~~
14+
~~~
1515
!!! error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type.
1616
~
1717
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.

tests/baselines/reference/noImplicitAnyModule.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tests/cases/compiler/noImplicitAnyModule.ts(5,9): error TS7013: Construct signature, which lacks return-type annotation, implicitly has an 'any' return type.
22
tests/cases/compiler/noImplicitAnyModule.ts(10,18): error TS7006: Parameter 'x' implicitly has an 'any' type.
3-
tests/cases/compiler/noImplicitAnyModule.ts(11,9): error TS7010: 'g', which lacks return-type annotation, implicitly has an 'any' return type.
3+
tests/cases/compiler/noImplicitAnyModule.ts(11,16): error TS7010: 'g', which lacks return-type annotation, implicitly has an 'any' return type.
44
tests/cases/compiler/noImplicitAnyModule.ts(18,14): error TS7010: 'f', which lacks return-type annotation, implicitly has an 'any' return type.
55

66

@@ -20,7 +20,7 @@ tests/cases/compiler/noImplicitAnyModule.ts(18,14): error TS7010: 'f', which lac
2020
~
2121
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.
2222
public g(x: any);
23-
~~~~~~~~~~~~~~~~~
23+
~
2424
!!! error TS7010: 'g', which lacks return-type annotation, implicitly has an 'any' return type.
2525

2626
// Should not return error at all.

tests/baselines/reference/overloadOnConstNoNonSpecializedSignature.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tests/cases/compiler/overloadOnConstNoNonSpecializedSignature.ts(2,4): error TS2
44
==== tests/cases/compiler/overloadOnConstNoNonSpecializedSignature.ts (1 errors) ====
55
class C {
66
x1(a: 'hi'); // error, no non-specialized signature in overload list
7-
~~~~~~~~~~~~
7+
~~
88
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
99
x1(a: string) { }
1010
}

tests/baselines/reference/parserParameterList16.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16.
55
==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16.ts (2 errors) ====
66
class C {
77
foo(a = 4);
8-
~~~~~~~~~~~
8+
~~~
99
!!! error TS2394: Overload signature is not compatible with function implementation.
1010
~~~~~
1111
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.

tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignat
2323

2424
class C {
2525
foo(x: 'a');
26-
~~~~~~~~~~~~
26+
~~~
2727
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
2828
foo(x: number);
2929
foo(x: any) { }
3030
}
3131

3232
class C2<T> {
3333
foo(x: 'a');
34-
~~~~~~~~~~~~
34+
~~~
3535
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
3636
foo(x: T);
3737
foo(x: any) { }
3838
}
3939

4040
class C3<T extends String> {
4141
foo(x: 'a');
42-
~~~~~~~~~~~~
42+
~~~
4343
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
4444
foo(x: T);
4545
foo(x: any) { }

tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon
7575
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
7676

7777
foo() { // error
78-
~~~~~~~~~~~~~~~~
78+
~~~
79+
!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'.
7980
return '';
80-
~~~~~~~~~~~~~~~~~~
8181
}
82-
~~~~~
83-
!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'.
8482

8583
static sa: number; // ok
8684
static sb: string; // ok

tests/baselines/reference/stringLiteralTypesInImplementationSignatures.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType
2626

2727
class C {
2828
foo(x: 'hi') { }
29-
~~~~~~~~~~~~~~~~
29+
~~~
3030
!!! error TS2381: A signature with an implementation cannot use a string literal type.
3131
}
3232

@@ -50,7 +50,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType
5050

5151
var b = {
5252
foo(x: 'hi') { },
53-
~~~~~~~~~~~~~~~~
53+
~~~
5454
!!! error TS2381: A signature with an implementation cannot use a string literal type.
5555
a: function foo(x: 'hi', y: 'hi') { },
5656
~~~

tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.errors.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType
2525
class C {
2626
foo(x: string);
2727
foo(x: 'hi') { }
28-
~~~~~~~~~~~~~~~~
28+
~~~
2929
!!! error TS2381: A signature with an implementation cannot use a string literal type.
3030
}
3131

@@ -63,12 +63,12 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType
6363
foo(x: 'hi') { },
6464
~~~
6565
!!! error TS2300: Duplicate identifier 'foo'.
66-
~~~~~~~~~~~~~~~~
66+
~~~
6767
!!! error TS2381: A signature with an implementation cannot use a string literal type.
6868
foo(x: 'a') { },
6969
~~~
7070
!!! error TS2300: Duplicate identifier 'foo'.
71-
~~~~~~~~~~~~~~~
71+
~~~
7272
!!! error TS2381: A signature with an implementation cannot use a string literal type.
7373
}
7474

tests/baselines/reference/typeCheckObjectLiteralMethodBody.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ tests/cases/compiler/typeCheckObjectLiteralMethodBody.ts(1,13): error TS7010: 'b
33

44
==== tests/cases/compiler/typeCheckObjectLiteralMethodBody.ts (1 errors) ====
55
var foo = { bar() { return undefined } };
6-
~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
~~~
77
!!! error TS7010: 'bar', which lacks return-type annotation, implicitly has an 'any' return type.

0 commit comments

Comments
 (0)