Merge pull request #7062 from Microsoft/useAccessorNamesForErrors

Use accessor names for error spans
This commit is contained in:
Daniel Rosenwasser 2016-02-12 20:18:38 -08:00
commit c7fcd0204c
19 changed files with 73 additions and 86 deletions

View File

@ -387,6 +387,8 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.TypeAliasDeclaration:
errorNode = (<Declaration>node).name;
break;

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts (1 errors) ====
@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8,
// Computed properties
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
set ["set1"](p: Foo2) { }
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts (1 errors) ====
@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8,
// Computed properties
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
set ["set1"](p: Foo2) { }
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8,9): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts (1 errors) ====
@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8,
// Computed properties
get [1 << 6]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'.
set [1 << 6](p: Foo2) { }
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8,9): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts (1 errors) ====
@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8,
// Computed properties
get [1 << 6]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'.
set [1 << 6](p: Foo2) { }
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8,9): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts (1 errors) ====
@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8,
// Computed properties
get [1 << 6]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'.
set [1 << 6](p: Foo2) { }
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8,9): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts (1 errors) ====
@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8,
// Computed properties
get [1 << 6]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'.
set [1 << 6](p: Foo2) { }
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts (1 errors) ====
@ -12,7 +12,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10
class D extends C {
// Computed properties
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
set ["set1"](p: Foo2) { }
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts (1 errors) ====
@ -12,7 +12,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10
class D extends C {
// Computed properties
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
set ["set1"](p: Foo2) { }
}

View File

@ -1,5 +1,5 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(6,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts (2 errors) ====
@ -9,12 +9,12 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10
class C {
[s: string]: Foo2;
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}
class D extends C {
set ["set1"](p: Foo) { }
~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}

View File

@ -1,5 +1,5 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(6,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts (2 errors) ====
@ -9,12 +9,12 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10
class C {
[s: string]: Foo2;
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}
class D extends C {
set ["set1"](p: Foo) { }
~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}

View File

@ -1,5 +1,5 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(5,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(5,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts (2 errors) ====
@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11
class C {
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}
@ -16,6 +16,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11
// No error when the indexer is in a class more derived than the computed property
[s: string]: Foo2;
set ["set1"](p: Foo) { }
~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}

View File

@ -1,5 +1,5 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(5,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(5,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts (2 errors) ====
@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11
class C {
get ["get1"]() { return new Foo }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}
@ -16,6 +16,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11
// No error when the indexer is in a class more derived than the computed property
[s: string]: Foo2;
set ["set1"](p: Foo) { }
~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
}

View File

@ -1,23 +1,21 @@
tests/cases/compiler/getAndSetNotIdenticalType.ts(2,5): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType.ts(2,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type.
==== tests/cases/compiler/getAndSetNotIdenticalType.ts (4 errors) ====
class C {
get x(): number {
~~~~~~~~~~~~~~~~~
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
return 1;
~~~~~~~~~~~~~~~~~
}
~~~~~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
set x(v: string) { }
~~~~~~~~~~~~~~~~~~~~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
}

View File

@ -1,7 +1,7 @@
tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,5): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A<string>' is not assignable to type 'A<T>'.
Type 'string' is not assignable to type 'T'.
@ -12,26 +12,22 @@ tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A<s
class C<T> {
data: A<T>;
get x(): A<T> {
~~~~~~~~~~~~~~~
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return this.data;
~~~~~~~~~~~~~~~~~~~~~~~~~
}
~~~~~
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
return this.data;
}
set x(v: A<string>) {
~~~~~~~~~~~~~~~~~~~~~
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
this.data = v;
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~
!!! error TS2322: Type 'A<string>' is not assignable to type 'A<T>'.
!!! error TS2322: Type 'string' is not assignable to type 'T'.
}
~~~~~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
}
var x = new C();

View File

@ -1,7 +1,7 @@
tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,5): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType3.ts(9,9): error TS2322: Type 'A<string>' is not assignable to type 'A<number>'.
Type 'string' is not assignable to type 'number'.
@ -12,26 +12,22 @@ tests/cases/compiler/getAndSetNotIdenticalType3.ts(9,9): error TS2322: Type 'A<s
class C<T> {
data: A<number>;
get x(): A<number> {
~~~~~~~~~~~~~~~~~~~~
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return this.data;
~~~~~~~~~~~~~~~~~~~~~~~~~
}
~~~~~
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
return this.data;
}
set x(v: A<string>) {
~~~~~~~~~~~~~~~~~~~~~
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
this.data = v;
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~
!!! error TS2322: Type 'A<string>' is not assignable to type 'A<number>'.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
}
~~~~~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
}
var x = new C();

View File

@ -8,7 +8,7 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(23,10): error TS7024: F
tests/cases/compiler/implicitAnyFromCircularInference.ts(26,10): error TS7023: 'h' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(28,14): error TS7023: 'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(41,5): error TS7022: 's' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(46,9): error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
==== tests/cases/compiler/implicitAnyFromCircularInference.ts (11 errors) ====
@ -78,11 +78,9 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x
class D {
// Error expected
get x() {
~~~~~~~~~
return this.x;
~~~~~~~~~~~~~~~~~~~~~~
}
~~~~~
~
!!! error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
return this.x;
}
}

View File

@ -1,11 +1,11 @@
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(3,5): error TS7008: Member 'getAndSet' implicitly has an 'any' type.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(4,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,5): error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,28): error TS7006: Parameter 'newXValue' implicitly has an 'any' type.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,5): error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type.
==== tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts (8 errors) ====
@ -30,24 +30,21 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): er
class SetterOnly {
public set haveOnlySet(newXValue) { // error at "haveOnlySet, newXValue"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~~~~~~~~~
!!! error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation.
~~~~~~~~~
!!! error TS7006: Parameter 'newXValue' implicitly has an 'any' type.
}
~~~~~
!!! error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation.
}
class GetterOnly {
public get haveOnlyGet() { // error at "haveOnlyGet"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return null;
~~~~~~~~~~~~~~~~~~~~
}
~~~~~
~~~~~~~~~~~
!!! error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type.
return null;
}
}

View File

@ -89,11 +89,11 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(39,26)
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,13): error TS2300: Duplicate identifier 'a'.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS1119: An object literal cannot have property and accessor with the same name.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS2300: Duplicate identifier 'a'.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,12): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,43): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,16): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,47): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,29): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,12): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,51): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,16): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55): error TS2380: 'get' and 'set' accessor must have the same type.
==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (96 errors) ====
@ -322,16 +322,16 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,51)
// Get and set accessor with mismatched type annotations
var g1 = { get a(): number { return 4; }, set a(n: string) { } };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
~~~~~~~~~~~~~~~~~~~~
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
var g2 = { get a() { return 4; }, set a(n: string) { } };
~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
var g3 = { get a(): number { return undefined; }, set a(n: string) { } };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
~~~~~~~~~~~~~~~~~~~~
~
!!! error TS2380: 'get' and 'set' accessor must have the same type.