File: getAndSetNotIdenticalType2.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (35 lines) | stat: -rw-r--r-- 1,582 bytes parent folder | download | duplicates (3)
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
tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A<string>' is not assignable to type 'A<T>'.
  Type 'string' is not assignable to type 'T'.


==== tests/cases/compiler/getAndSetNotIdenticalType2.ts (5 errors) ====
    class A<T> { foo: T; }
    
    class C<T> {
        data: A<T>;
        get x(): A<T> {
            ~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
            ~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
            return this.data;
        }
        set x(v: A<string>) {
            ~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
            ~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
            this.data = v;
            ~~~~~~~~~
!!! error TS2322: Type 'A<string>' is not assignable to type 'A<T>'.
!!! error TS2322:   Type 'string' is not assignable to type 'T'.
        }
    }
    
    var x = new C();
    var r = x.x;
    x.x = r;