TypeScript/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt
2014-09-11 16:11:08 -07:00

43 lines
1.8 KiB
Plaintext

==== tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts (8 errors) ====
// these should be errors
class GetAndSet {
getAndSet = null; // error at "getAndSet"
~~~~~~~~~~~~~~~~~
!!! error TS7008: Member 'getAndSet' implicitly has an 'any' type.
public get haveGetAndSet() { // this should not be an error
~~~~~~~~~~~~~
!!! error TS1056: 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"
~~~~~~~~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
this.getAndSet = value;
}
}
class SetterOnly {
public set haveOnlySet(newXValue) { // error at "haveOnlySet, newXValue"
~~~~~~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~
!!! 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.
}