2014-07-19 00:19:23 +02:00
|
|
|
==== tests/cases/compiler/gettersAndSettersErrors.ts (10 errors) ====
|
2014-07-13 01:04:16 +02:00
|
|
|
class C {
|
|
|
|
public get Foo() { return "foo";} // ok
|
|
|
|
~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
public set Foo(foo:string) {} // ok
|
|
|
|
~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
|
|
|
|
public Foo = 0; // error - duplicate identifier Foo - confirmed
|
|
|
|
~~~
|
|
|
|
!!! Duplicate identifier 'Foo'.
|
|
|
|
public get Goo(v:string):string {return null;} // error - getters must not have a parameter
|
|
|
|
~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
public set Goo(v:string):string {} // error - setters must not specify a return type
|
|
|
|
~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
2014-07-19 00:19:23 +02:00
|
|
|
~~~~~~
|
2014-07-21 20:36:29 +02:00
|
|
|
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class E {
|
|
|
|
private get Baz():number { return 0; }
|
|
|
|
~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
~~~
|
|
|
|
!!! Getter and setter accessors do not agree in visibility.
|
|
|
|
public set Baz(n:number) {} // error - accessors do not agree in visibility
|
|
|
|
~~~
|
|
|
|
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
~~~
|
|
|
|
!!! Getter and setter accessors do not agree in visibility.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|