37 lines
No EOL
1.6 KiB
Text
37 lines
No EOL
1.6 KiB
Text
==== tests/cases/compiler/gettersAndSettersErrors.ts (10 errors) ====
|
|
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.
|
|
~~~~~~
|
|
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
}
|
|
|
|
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.
|
|
}
|
|
|
|
|
|
|