File: mixinAccessModifiers.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (202 lines) | stat: -rw-r--r-- 11,337 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
tests/cases/conformance/classes/mixinAccessModifiers.ts(38,4): error TS2339: Property 'p' does not exist on type 'never'.
  The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(42,4): error TS2339: Property 'p' does not exist on type 'never'.
  The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(46,4): error TS2339: Property 'p' does not exist on type 'never'.
  The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(50,4): error TS2445: Property 'p' is protected and only accessible within class 'Protected & Protected2' and its subclasses.
tests/cases/conformance/classes/mixinAccessModifiers.ts(65,18): error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
  The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(66,18): error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
  The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(67,18): error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
  The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(84,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses.
tests/cases/conformance/classes/mixinAccessModifiers.ts(89,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
tests/cases/conformance/classes/mixinAccessModifiers.ts(97,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses.
tests/cases/conformance/classes/mixinAccessModifiers.ts(102,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
tests/cases/conformance/classes/mixinAccessModifiers.ts(119,4): error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
tests/cases/conformance/classes/mixinAccessModifiers.ts(120,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
tests/cases/conformance/classes/mixinAccessModifiers.ts(124,4): error TS2339: Property 'privateMethod' does not exist on type 'never'.
  The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(125,4): error TS2339: Property 'protectedMethod' does not exist on type 'never'.
  The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
tests/cases/conformance/classes/mixinAccessModifiers.ts(129,4): error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
tests/cases/conformance/classes/mixinAccessModifiers.ts(130,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.


==== tests/cases/conformance/classes/mixinAccessModifiers.ts (17 errors) ====
    type Constructable = new (...args: any[]) => object;
    
    class Private {
    	constructor (...args: any[]) {}
    	private p: string;
    }
    
    class Private2 {
    	constructor (...args: any[]) {}
    	private p: string;
    }
    
    class Protected {
    	constructor (...args: any[]) {}
    	protected p: string;
    	protected static s: string;
    }
    
    class Protected2 {
    	constructor (...args: any[]) {}
    	protected p: string;
    	protected static s: string;
    }
    
    class Public {
    	constructor (...args: any[]) {}
    	public p: string;
    	public static s: string;
    }
    
    class Public2 {
    	constructor (...args: any[]) {}
    	public p: string;
    	public static s: string;
    }
    
    function f1(x: Private & Private2) {
    	x.p;  // Error, private constituent makes property inaccessible
    	  ~
!!! error TS2339: Property 'p' does not exist on type 'never'.
!!! error TS2339:   The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
    }
    
    function f2(x: Private & Protected) {
    	x.p;  // Error, private constituent makes property inaccessible
    	  ~
!!! error TS2339: Property 'p' does not exist on type 'never'.
!!! error TS2339:   The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
    }
    
    function f3(x: Private & Public) {
    	x.p;  // Error, private constituent makes property inaccessible
    	  ~
!!! error TS2339: Property 'p' does not exist on type 'never'.
!!! error TS2339:   The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
    }
    
    function f4(x: Protected & Protected2) {
    	x.p;  // Error, protected when all constituents are protected
    	  ~
!!! error TS2445: Property 'p' is protected and only accessible within class 'Protected & Protected2' and its subclasses.
    }
    
    function f5(x: Protected & Public) {
    	x.p;  // Ok, public if any constituent is public
    }
    
    function f6(x: Public & Public2) {
    	x.p;  // Ok, public if any constituent is public
    }
    
    declare function Mix<T, U>(c1: T, c2: U): T & U;
    
    // Can't derive from type with inaccessible properties
    
    class C1 extends Mix(Private, Private2) {}
                     ~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
!!! error TS2509:   The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
    class C2 extends Mix(Private, Protected) {}
                     ~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
!!! error TS2509:   The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
    class C3 extends Mix(Private, Public) {}
                     ~~~~~~~~~~~~~~~~~~~~
!!! error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
!!! error TS2509:   The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
    
    class C4 extends Mix(Protected, Protected2) {
    	f(c4: C4, c5: C5, c6: C6) {
    		c4.p;
    		c5.p;
    		c6.p;
    	}
    	static g() {
    		C4.s;
    		C5.s;
    		C6.s
    	}
    }
    
    class C5 extends Mix(Protected, Public) {
    	f(c4: C4, c5: C5, c6: C6) {
    		c4.p;  // Error, not in class deriving from Protected2
    		   ~
!!! error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses.
    		c5.p;
    		c6.p;
    	}
    	static g() {
    		C4.s;  // Error, not in class deriving from Protected2
    		   ~
!!! error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
    		C5.s;
    		C6.s
    	}
    }
    
    class C6 extends Mix(Public, Public2) {
    	f(c4: C4, c5: C5, c6: C6) {
    		c4.p;  // Error, not in class deriving from Protected2
    		   ~
!!! error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses.
    		c5.p;
    		c6.p;
    	}
    	static g() {
    		C4.s;  // Error, not in class deriving from Protected2
    		   ~
!!! error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
    		C5.s;
    		C6.s
    	}
    }
    
    class ProtectedGeneric<T> {
    	private privateMethod() {}
    	protected protectedMethod() {}
    }
    
    class ProtectedGeneric2<T> {
    	private privateMethod() {}
    	protected protectedMethod() {}
    }
    
    function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) {
    	x.privateMethod(); // Error, private constituent makes method inaccessible
    	  ~~~~~~~~~~~~~
!!! error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
    	x.protectedMethod(); // Error, protected when all constituents are protected
    	  ~~~~~~~~~~~~~~~
!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
    }
    
    function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) {
    	x.privateMethod(); // Error, private constituent makes method inaccessible
    	  ~~~~~~~~~~~~~
!!! error TS2339: Property 'privateMethod' does not exist on type 'never'.
!!! error TS2339:   The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
    	x.protectedMethod(); // Error, protected when all constituents are protected
    	  ~~~~~~~~~~~~~~~
!!! error TS2339: Property 'protectedMethod' does not exist on type 'never'.
!!! error TS2339:   The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
    }
    
    function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
    	x.privateMethod(); // Error, private constituent makes method inaccessible
    	  ~~~~~~~~~~~~~
!!! error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
    	x.protectedMethod(); // Error, protected when all constituents are protected
    	  ~~~~~~~~~~~~~~~
!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
    }