2014-08-01 00:56:00 +02:00
|
|
|
==== tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts (8 errors) ====
|
2014-07-13 01:04:16 +02:00
|
|
|
// these should be errors
|
|
|
|
class GetAndSet {
|
|
|
|
getAndSet = null; // error at "getAndSet"
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
!!! Member 'getAndSet' implicitly has an 'any' type.
|
|
|
|
public get haveGetAndSet() { // this should not be an error
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
return this.getAndSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this shouldn't be an error
|
|
|
|
public set haveGetAndSet(value) { // error at "value"
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
this.getAndSet = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SetterOnly {
|
|
|
|
public set haveOnlySet(newXValue) { // error at "haveOnlySet, newXValue"
|
|
|
|
~~~~~~~~~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
~~~~~~~~~
|
|
|
|
!!! Parameter 'newXValue' implicitly has an 'any' type.
|
|
|
|
}
|
|
|
|
~~~~~
|
|
|
|
!!! Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation.
|
|
|
|
}
|
|
|
|
|
|
|
|
class GetterOnly {
|
|
|
|
public get haveOnlyGet() { // error at "haveOnlyGet"
|
|
|
|
~~~~~~~~~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
return null;
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
}
|
|
|
|
~~~~~
|
|
|
|
!!! 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type.
|
|
|
|
}
|