File: emitClassExpressionInDeclarationFile2.errors.txt

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (41 lines) | stat: -rw-r--r-- 1,693 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'p' of exported class expression may not be private or protected.
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'ps' of exported class expression may not be private or protected.
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(16,17): error TS4094: Property 'property' of exported class expression may not be private or protected.


==== tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts (3 errors) ====
    export var noPrivates = class {
               ~~~~~~~~~~
!!! error TS4094: Property 'p' of exported class expression may not be private or protected.
               ~~~~~~~~~~
!!! error TS4094: Property 'ps' of exported class expression may not be private or protected.
        static getTags() { }
        tags() { }
        private static ps = -1
        private p = 12
    }
    
    // altered repro from #15066 to add private property
    export class FooItem {
        foo(): void { }
        name?: string;
        private property = "capitalism"
    }
    
    export type Constructor<T> = new(...args: any[]) => T;
    export function WithTags<T extends Constructor<FooItem>>(Base: T) {
                    ~~~~~~~~
!!! error TS4094: Property 'property' of exported class expression may not be private or protected.
        return class extends Base {
            static getTags(): void { }
            tags(): void { }
        }
    }
    
    export class Test extends WithTags(FooItem) {}
    
    const test = new Test();
    
    Test.getTags()
    test.tags();