==== tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts (34 errors) ==== // Get and set accessor with the same name var sameName1a = { get 'a'() { return ''; }, set a(n) { var p = n; var p: string; } }; ~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameName2a = { get 0.0() { return ''; }, set 0(n) { var p = n; var p: string; } }; ~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameName3a = { get 0x20() { return ''; }, set 3.2e1(n) { var p = n; var p: string; } }; ~~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~~~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameName4a = { get ''() { return ''; }, set ""(n) { var p = n; var p: string; } }; ~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameName5a = { get '\t'() { return ''; }, set '\t'(n) { var p = n; var p: string; } }; ~~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameName6a = { get 'a'() { return ''; }, set a(n) { var p = n; var p: string; } }; ~~~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. // PropertyName CallSignature{FunctionBody} is equivalent to PropertyName:function CallSignature{FunctionBody} var callSig1 = { num(n: number) { return '' } }; var callSig1: { num: (n: number) => string; }; var callSig2 = { num: function (n: number) { return '' } }; var callSig2: { num: (n: number) => string; }; var callSig3 = { num: (n: number) => '' }; var callSig3: { num: (n: number) => string; }; // Get accessor only, type of the property is the annotated return type of the get accessor var getter1 = { get x(): string { return undefined; } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var getter1: { x: string; } // Get accessor only, type of the property is the inferred return type of the get accessor var getter2 = { get x() { return ''; } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var getter2: { x: string; } // Set accessor only, type of the property is the param type of the set accessor var setter1 = { set x(n: number) { } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var setter1: { x: number }; // Set accessor only, type of the property is Any for an unannotated set accessor var setter2 = { set x(n) { } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var setter2: { x: any }; var anyVar: any; // Get and set accessor with matching type annotations var sameType1 = { get x(): string { return undefined; }, set x(n: string) { } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameType2 = { get x(): Array { return undefined; }, set x(n: number[]) { } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameType3 = { get x(): any { return undefined; }, set x(n: typeof anyVar) { } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var sameType4 = { get x(): Date { return undefined; }, set x(n: Date) { } }; ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. // Type of unannotated get accessor return type is the type annotation of the set accessor param var setParamType1 = { set n(x: (t: string) => void) { }, ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. get n() { return (t) => { ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var p: string; var p = t; } } }; var setParamType2 = { get n() { return (t) => { ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var p: string; var p = t; } }, set n(x: (t: string) => void) { } ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. }; // Type of unannotated set accessor parameter is the return type annotation of the get accessor var getParamType1 = { set n(x) { ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var y = x; var y: string; }, get n() { return ''; } ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. }; var getParamType2 = { get n() { return ''; }, ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. set n(x) { ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var y = x; var y: string; } }; // Type of unannotated accessors is the inferred return type of the get accessor var getParamType3 = { get n() { return ''; }, ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. set n(x) { ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. var y = x; var y: string; } };