TypeScript/tests/baselines/reference/gettersAndSetters.errors.txt
2014-07-12 17:30:19 -07:00

57 lines
1.8 KiB
Plaintext

==== tests/cases/compiler/gettersAndSetters.ts (8 errors) ====
// classes
class C {
public fooBack = "";
static barBack:string = "";
public bazBack = "";
public get Foo() { return this.fooBack;} // ok
~~~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
public set Foo(foo:string) {this.fooBack = foo;} // ok
~~~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
static get Bar() {return C.barBack;} // ok
~~~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
static set Bar(bar:string) {C.barBack = bar;} // ok
~~~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
public get = function() {} // ok
public set = function() {} // ok
}
var c = new C();
var foo = c.Foo;
c.Foo = "foov";
var bar = C.Bar;
C.Bar = "barv";
var baz = c.Baz;
~~~
!!! Property 'Baz' does not exist on type 'C'.
c.Baz = "bazv";
~~~
!!! Property 'Baz' does not exist on type 'C'.
// The Foo accessors' return and param types should be contextually typed to the Foo field
var o : {Foo:number;} = {get Foo() {return 0;}, set Foo(val:number){val}}; // o
~~~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
var ofg = o.Foo;
o.Foo = 0;
interface I1 {
(n:number):number;
}
var i:I1 = function (n) {return n;}