@@ -8,194 +8,199 @@ type IsEqual<X, Y> = (
88) ? true
99 : false ;
1010
11- Deno . test ( 'Concrete' , ( ) => {
12- abstract class Base {
13- public readonly a : number ;
14- protected readonly b : number ;
15- private readonly c : number ;
16-
17- constructor ( a : number , b : number , c ?: number ) {
18- this . a = a ;
19- this . b = b ;
20- this . c = c ?? 0 ;
21- }
22-
23- values ( ) : [ number , number , number ] {
24- return [ this . a , this . b , this . c ] ;
25- }
11+ abstract class BaseA {
12+ public readonly a : number ;
13+ protected readonly b : number ;
14+ private readonly c : number ;
15+
16+ constructor ( a : number , b : number , c ?: number ) {
17+ this . a = a ;
18+ this . b = b ;
19+ this . c = c ?? 0 ;
20+ }
2621
27- public static readonly PUB = 1 ;
28- protected static readonly PRO = 2 ;
29- private static readonly PRI = 3 ;
22+ values ( ) : [ number , number , number ] {
23+ return [ this . a , this . b , this . c ] ;
24+ }
3025
31- static values ( ) : [ number , number , number ] {
32- return [ this . PUB , this . PRO , this . PRI ] ;
33- }
26+ public static readonly PUB = 1 ;
27+ protected static readonly PRO = 2 ;
28+ private static readonly PRI = 3 ;
3429
35- static new ( ) : string {
36- return 'new' ;
37- }
30+ static values ( ) : [ number , number , number ] {
31+ return [ this . PUB , this . PRO , this . PRI ] ;
3832 }
3933
40- class Impl extends Base { }
41-
42- {
43- const CB : Concrete < typeof Base > = Impl ;
34+ static new ( ) : string {
35+ return 'new' ;
36+ }
37+ }
4438
45- assert ( true satisfies IsEqual < ( typeof CB ) [ 'prototype' ] , Base > ) ;
46- assert (
47- true satisfies IsEqual <
48- ConstructorParameters < typeof CB > ,
49- [ a : number , b : number , c ?: number | undefined ]
50- > ,
51- ) ;
52- assert ( true satisfies IsEqual < InstanceType < typeof CB > , Impl > ) ;
39+ class BaseC {
40+ public readonly a : number ;
41+ protected readonly b : number ;
42+ private readonly c : number ;
5343
54- assertEquals ( ( new CB ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
55- assertEquals ( ( new CB ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
56- assertEquals ( CB . values ( ) , [ 1 , 2 , 3 ] ) ;
57- assertEquals ( CB . new ( ) , 'new' ) ;
44+ constructor ( a : number , b : number , c ?: number ) {
45+ this . a = a ;
46+ this . b = b ;
47+ this . c = c ?? 0 ;
5848 }
5949
60- {
61- const CI : Concrete < typeof Impl > = Impl ;
62-
63- assert ( true satisfies IsEqual < ( typeof CI ) [ 'prototype' ] , Impl > ) ;
64- assert (
65- true satisfies IsEqual <
66- ConstructorParameters < typeof CI > ,
67- [ a : number , b : number , c ?: number | undefined ]
68- > ,
69- ) ;
70- assert ( true satisfies IsEqual < InstanceType < typeof CI > , Impl > ) ;
71-
72- assertEquals ( ( new CI ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
73- assertEquals ( ( new CI ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
74- assertEquals ( CI . values ( ) , [ 1 , 2 , 3 ] ) ;
75- assertEquals ( CI . new ( ) , 'new' ) ;
50+ values ( ) : [ number , number , number ] {
51+ return [ this . a , this . b , this . c ] ;
7652 }
7753
78- {
79- const CI : Concrete < typeof Impl > = Impl ;
80- assert ( new CI ( 1 , 2 ) ) ;
81- }
54+ public static readonly PUB = 1 ;
55+ protected static readonly PRO = 2 ;
56+ private static readonly PRI = 3 ;
8257
83- {
84- // @ts -expect-error Class only.
85- // deno-lint-ignore ban-types
86- type Bad = Concrete < Function > ;
87- assert ( true satisfies IsEqual < Bad , never > ) ;
58+ static values ( ) : [ number , number , number ] {
59+ return [ this . PUB , this . PRO , this . PRI ] ;
8860 }
8961
90- {
91- // @ts -expect-error Class only.
92- type Bad = Concrete < ( ) => void > ;
93- assert ( true satisfies IsEqual < Bad , never > ) ;
62+ static new ( ) : string {
63+ return 'new' ;
9464 }
65+ }
66+
67+ Deno . test ( 'Concrete: abstract' , ( ) => {
68+ class Impl extends BaseA { }
69+ const CB : Concrete < typeof BaseA > = Impl ;
70+
71+ assert ( true satisfies IsEqual < ( typeof CB ) [ 'prototype' ] , BaseA > ) ;
72+ assert (
73+ true satisfies IsEqual <
74+ ConstructorParameters < typeof CB > ,
75+ [ a : number , b : number , c ?: number | undefined ]
76+ > ,
77+ ) ;
78+ assert ( true satisfies IsEqual < InstanceType < typeof CB > , Impl > ) ;
79+
80+ assertEquals ( ( new CB ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
81+ assertEquals ( ( new CB ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
82+ assertEquals ( CB . values ( ) , [ 1 , 2 , 3 ] ) ;
83+ assertEquals ( CB . new ( ) , 'new' ) ;
9584} ) ;
9685
97- Deno . test ( 'Abstract' , ( ) => {
98- class Real {
99- public readonly a : number ;
100- protected readonly b : number ;
101- private readonly c : number ;
86+ Deno . test ( 'Concrete: concrete' , ( ) => {
87+ class Impl extends BaseA { }
88+ const CI : Concrete < typeof Impl > = Impl ;
89+
90+ assert ( true satisfies IsEqual < ( typeof CI ) [ 'prototype' ] , Impl > ) ;
91+ assert (
92+ true satisfies IsEqual <
93+ ConstructorParameters < typeof CI > ,
94+ [ a : number , b : number , c ?: number | undefined ]
95+ > ,
96+ ) ;
97+ assert ( true satisfies IsEqual < InstanceType < typeof CI > , Impl > ) ;
98+
99+ assertEquals ( ( new CI ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
100+ assertEquals ( ( new CI ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
101+ assertEquals ( CI . values ( ) , [ 1 , 2 , 3 ] ) ;
102+ assertEquals ( CI . new ( ) , 'new' ) ;
103+ } ) ;
102104
103- constructor ( a : number , b : number , c ?: number ) {
104- this . a = a ;
105- this . b = b ;
106- this . c = c ?? 0 ;
107- }
105+ Deno . test ( 'Concrete: new' , ( ) => {
106+ class Impl extends BaseA { }
107+ const CI : Concrete < typeof Impl > = Impl ;
108+ assert ( new CI ( 1 , 2 ) ) ;
109+ } ) ;
108110
109- values ( ) : [ number , number , number ] {
110- return [ this . a , this . b , this . c ] ;
111- }
111+ Deno . test ( 'Concrete: function' , ( ) => {
112+ // @ts -expect-error Class only.
113+ type Bad = Concrete < ( ) => void > ;
114+ assert ( true satisfies IsEqual < Bad , never > ) ;
115+ } ) ;
112116
113- public static readonly PUB = 1 ;
114- protected static readonly PRO = 2 ;
115- private static readonly PRI = 3 ;
117+ Deno . test ( 'Concrete: super' , ( ) => {
118+ const Base : Concrete < typeof BaseA > = class Base extends BaseA { } ;
116119
117- static values ( ) : [ number , number , number ] {
118- return [ this . PUB , this . PRO , this . PRI ] ;
120+ class GoodSuper extends Base {
121+ constructor ( ) {
122+ super ( 1 , 2 , 3 ) ;
119123 }
124+ }
125+ assert ( GoodSuper ) ;
120126
121- static new ( ) : string {
122- return 'new' ;
127+ class BadSuper extends Base {
128+ constructor ( ) {
129+ // @ts -expect-error Arguments.
130+ super ( ) ;
123131 }
124132 }
133+ assert ( BadSuper ) ;
134+ } ) ;
125135
126- const Base : Abstract < typeof Real > = Real ;
127-
128- class Impl extends Base { }
129-
130- {
131- const CB : Concrete < typeof Base > = Impl ;
132-
133- assert ( true satisfies IsEqual < ( typeof CB ) [ 'prototype' ] , Real > ) ;
134- assert (
135- true satisfies IsEqual <
136- ConstructorParameters < typeof CB > ,
137- [ a : number , b : number , c ?: number | undefined ]
138- > ,
139- ) ;
140- assert ( true satisfies IsEqual < InstanceType < typeof CB > , Impl > ) ;
141-
142- assertEquals ( ( new CB ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
143- assertEquals ( ( new CB ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
144- assertEquals ( CB . values ( ) , [ 1 , 2 , 3 ] ) ;
145- assertEquals ( CB . new ( ) , 'new' ) ;
146- }
136+ Deno . test ( 'Abstract: abstract' , ( ) => {
137+ const BaseA : Abstract < typeof BaseC > = BaseC ;
138+ class Impl extends BaseA { }
139+ const CB : Concrete < typeof BaseA > = Impl ;
140+
141+ assert ( true satisfies IsEqual < ( typeof CB ) [ 'prototype' ] , BaseC > ) ;
142+ assert (
143+ true satisfies IsEqual <
144+ ConstructorParameters < typeof CB > ,
145+ [ a : number , b : number , c ?: number | undefined ]
146+ > ,
147+ ) ;
148+ assert ( true satisfies IsEqual < InstanceType < typeof CB > , Impl > ) ;
149+
150+ assertEquals ( ( new CB ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
151+ assertEquals ( ( new CB ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
152+ assertEquals ( CB . values ( ) , [ 1 , 2 , 3 ] ) ;
153+ assertEquals ( CB . new ( ) , 'new' ) ;
154+ } ) ;
147155
148- {
149- const CI : Concrete < typeof Impl > = Impl ;
150-
151- assert ( true satisfies IsEqual < ( typeof CI ) [ 'prototype' ] , Impl > ) ;
152- assert (
153- true satisfies IsEqual <
154- ConstructorParameters < typeof CI > ,
155- [ a : number , b : number , c ?: number | undefined ]
156- > ,
157- ) ;
158- assert ( true satisfies IsEqual < InstanceType < typeof CI > , Impl > ) ;
159-
160- assertEquals ( ( new CI ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
161- assertEquals ( ( new CI ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
162- assertEquals ( CI . values ( ) , [ 1 , 2 , 3 ] ) ;
163- assertEquals ( CI . new ( ) , 'new' ) ;
164- }
156+ Deno . test ( 'Abstract: concrete' , ( ) => {
157+ const BaseA : Abstract < typeof BaseC > = BaseC ;
158+ class Impl extends BaseA { }
159+ const CI : Concrete < typeof Impl > = Impl ;
160+
161+ assert ( true satisfies IsEqual < ( typeof CI ) [ 'prototype' ] , Impl > ) ;
162+ assert (
163+ true satisfies IsEqual <
164+ ConstructorParameters < typeof CI > ,
165+ [ a : number , b : number , c ?: number | undefined ]
166+ > ,
167+ ) ;
168+ assert ( true satisfies IsEqual < InstanceType < typeof CI > , Impl > ) ;
169+
170+ assertEquals ( ( new CI ( 1 , 2 ) ) . values ( ) , [ 1 , 2 , 0 ] ) ;
171+ assertEquals ( ( new CI ( 1 , 2 , 3 ) ) . values ( ) , [ 1 , 2 , 3 ] ) ;
172+ assertEquals ( CI . values ( ) , [ 1 , 2 , 3 ] ) ;
173+ assertEquals ( CI . new ( ) , 'new' ) ;
174+ } ) ;
165175
166- {
167- const CB : Abstract < typeof Base > = Base ;
168- // @ts -expect-error Abstract.
169- const o = new CB ( 1 , 2 ) ;
170- assert ( o ) ;
171- }
176+ Deno . test ( 'Abstract: new' , ( ) => {
177+ const CB : Abstract < typeof BaseA > = BaseA ;
178+ // @ts -expect-error Abstract.
179+ const o = new CB ( 1 , 2 ) ;
180+ assert ( o ) ;
181+ } ) ;
172182
173- {
174- // @ts -expect-error Class only.
175- // deno-lint-ignore ban-types
176- type Bad = Abstract < Function > ;
177- assert ( true satisfies IsEqual < Bad , never > ) ;
178- }
183+ Deno . test ( 'Abstract: function' , ( ) => {
184+ // @ts -expect-error Class only.
185+ type Bad = Abstract < ( ) => void > ;
186+ assert ( true satisfies IsEqual < Bad , never > ) ;
187+ } ) ;
179188
180- {
181- // @ts -expect-error Class only.
182- type Bad = Abstract < ( ) => void > ;
183- assert ( true satisfies IsEqual < Bad , never > ) ;
184- }
189+ Deno . test ( 'Abstract: super' , ( ) => {
190+ const Base : Abstract < typeof BaseC > = class Base extends BaseC { } ;
185191
186- {
187- // @ts -expect-error Abstract.
188- const o = new Base ( ) ;
189- assert ( o ) ;
192+ class GoodSuper extends Base {
193+ constructor ( ) {
194+ super ( 1 , 2 , 3 ) ;
195+ }
190196 }
197+ assert ( GoodSuper ) ;
191198
192- {
193- class BadSuper extends Base {
194- constructor ( ) {
195- // @ts -expect-error Abstract.
196- super ( ) ;
197- }
199+ class BadSuper extends Base {
200+ constructor ( ) {
201+ // @ts -expect-error Arguments.
202+ super ( ) ;
198203 }
199- assert ( BadSuper ) ;
200204 }
205+ assert ( BadSuper ) ;
201206} ) ;
0 commit comments