27 lines
No EOL
1.3 KiB
Text
27 lines
No EOL
1.3 KiB
Text
==== tests/cases/compiler/gettersAndSettersTypesAgree.ts (8 errors) ====
|
|
class C {
|
|
public get Foo() { return "foo";} // ok
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
public set Foo(foo) {} // ok - type inferred from getter return statement
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
public get Bar() { return "foo";} // ok
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
public set Bar(bar:string) {} // ok - type must be declared
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
}
|
|
|
|
var o1 = {get Foo(){return 0;}, set Foo(val){}}; // ok - types agree (inference)
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
var o2 = {get Foo(){return 0;}, set Foo(val:number){}}; // ok - types agree
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
~~~
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher. |