Merge pull request #5972 from reavowed/master

Limit error reporting for methods to the method name
This commit is contained in:
Daniel Rosenwasser
2015-12-09 17:14:42 -08:00
19 changed files with 39 additions and 45 deletions

View File

@@ -342,6 +342,7 @@ namespace ts {
case SyntaxKind.EnumMember:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
errorNode = (<Declaration>node).name;
break;
}

View File

@@ -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,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.
}

View File

@@ -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,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.
}

View File

@@ -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 }
~~~~

View File

@@ -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 }
~~~~

View File

@@ -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.
};
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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) { }
}

View File

@@ -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.

View File

@@ -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<T> {
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<T extends String> {
foo(x: 'a');
~~~~~~~~~~~~
~~~
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
foo(x: T);
foo(x: any) { }

View File

@@ -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

View File

@@ -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') { },
~~~

View File

@@ -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.
}

View File

@@ -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.