File: stringIndexerAssignments2.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (35 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download | duplicates (4)
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/stringIndexerAssignments2.ts(19,1): error TS2322: Type 'C2' is not assignable to type 'C1'.
  Index signature is missing in type 'C2'.
tests/cases/compiler/stringIndexerAssignments2.ts(20,1): error TS2322: Type 'C3' is not assignable to type 'C1'.
  Types of property 'one' are incompatible.
    Type 'number' is not assignable to type 'string'.


==== tests/cases/compiler/stringIndexerAssignments2.ts (2 errors) ====
    class C1 {
        [index: string]: string
        one: string;
    }
    
    class C2 {
        one: string;
    }
    
    class C3 {
        one: number;
        two: string;
    }
    
    var x: C1;
    var a: C2;
    var b: C3;
    
    x = a;
    ~
!!! error TS2322: Type 'C2' is not assignable to type 'C1'.
!!! error TS2322:   Index signature is missing in type 'C2'.
    x = b;
    ~
!!! error TS2322: Type 'C3' is not assignable to type 'C1'.
!!! error TS2322:   Types of property 'one' are incompatible.
!!! error TS2322:     Type 'number' is not assignable to type 'string'.