File: privateNamesInNestedClasses-1.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (34 lines) | stat: -rw-r--r-- 1,590 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
tests/cases/conformance/classes/members/privateNames/privateNamesInNestedClasses-1.ts(11,18): error TS18014: The property '#foo' cannot be accessed on type 'A' within this class because it is shadowed by another private identifier with the same spelling.


==== tests/cases/conformance/classes/members/privateNames/privateNamesInNestedClasses-1.ts (1 errors) ====
    class A {
       #foo = "A's #foo";
       #bar = "A's #bar";
       method () {
           class B {
               #foo = "B's #foo";
               bar (a: any) {
                   a.#foo; // OK, no compile-time error, don't know what `a` is
               }
               baz (a: A) {
                   a.#foo; // compile-time error, shadowed
                     ~~~~
!!! error TS18014: The property '#foo' cannot be accessed on type 'A' within this class because it is shadowed by another private identifier with the same spelling.
!!! related TS18017 tests/cases/conformance/classes/members/privateNames/privateNamesInNestedClasses-1.ts:6:12: The shadowing declaration of '#foo' is defined here
!!! related TS18018 tests/cases/conformance/classes/members/privateNames/privateNamesInNestedClasses-1.ts:2:4: The declaration of '#foo' that you probably intended to use is defined here
               }
               quux (b: B) {
                   b.#foo; // OK
               }
           }
           const a = new A();
           new B().bar(a);
           new B().baz(a);
           const b = new B();
           new B().quux(b);
       }
    }
    
    new A().method();