1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
tests/cases/compiler/gettersAndSetters.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/gettersAndSetters.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/gettersAndSetters.ts(10,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/gettersAndSetters.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/gettersAndSetters.ts(25,13): error TS2339: Property 'Baz' does not exist on type 'C'.
tests/cases/compiler/gettersAndSetters.ts(26,3): error TS2339: Property 'Baz' does not exist on type 'C'.
tests/cases/compiler/gettersAndSetters.ts(29,30): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/gettersAndSetters.ts(29,53): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
==== tests/cases/compiler/gettersAndSetters.ts (8 errors) ====
// classes
class C {
public fooBack = "";
static barBack:string = "";
public bazBack = "";
public get Foo() { return this.fooBack;} // ok
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
public set Foo(foo:string) {this.fooBack = foo;} // ok
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
static get Bar() {return C.barBack;} // ok
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
static set Bar(bar:string) {C.barBack = bar;} // ok
~~~
!!! error TS1056: 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;
~~~
!!! error TS2339: Property 'Baz' does not exist on type 'C'.
c.Baz = "bazv";
~~~
!!! error TS2339: 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
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS1056: 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;}
|