File: classStaticPropertyAccess.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (33 lines) | stat: -rw-r--r-- 1,710 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
tests/cases/compiler/classStaticPropertyAccess.ts(10,1): error TS2576: Property '"' does not exist on type 'A'. Did you mean to access the static member 'A["\""]' instead?
tests/cases/compiler/classStaticPropertyAccess.ts(11,1): error TS2576: Property 'y' does not exist on type 'A'. Did you mean to access the static member 'A['y']' instead?
tests/cases/compiler/classStaticPropertyAccess.ts(12,3): error TS2576: Property 'y' does not exist on type 'A'. Did you mean to access the static member 'A.y' instead?
tests/cases/compiler/classStaticPropertyAccess.ts(13,3): error TS2341: Property '_b' is private and only accessible within class 'A'.
tests/cases/compiler/classStaticPropertyAccess.ts(14,3): error TS2339: Property 'a' does not exist on type 'typeof A'.


==== tests/cases/compiler/classStaticPropertyAccess.ts (5 errors) ====
    class A {
        public static "\""() {}
        public static x: number = 1;
        public static y: number = 1;
        private static _b: number = 2;
    }
    
    const a = new A();
    
    a["\""] // Error
    ~~~~~~~
!!! error TS2576: Property '"' does not exist on type 'A'. Did you mean to access the static member 'A["\""]' instead?
    a['y']  // Error
    ~~~~~~
!!! error TS2576: Property 'y' does not exist on type 'A'. Did you mean to access the static member 'A['y']' instead?
    a.y     // Error
      ~
!!! error TS2576: Property 'y' does not exist on type 'A'. Did you mean to access the static member 'A.y' instead?
    A._b    // Error
      ~~
!!! error TS2341: Property '_b' is private and only accessible within class 'A'.
    A.a
      ~
!!! error TS2339: Property 'a' does not exist on type 'typeof A'.