@@ -153,10 +153,80 @@ function f42(x: number) {
153
153
}
154
154
x ; // Unreachable
155
155
}
156
+
157
+ // Repro from #33582
158
+
159
+ export interface Component < T extends object = any > {
160
+ attrName ?: string ;
161
+ data : T ;
162
+ dependencies ?: string [ ] ;
163
+ el : any ;
164
+ id : string ;
165
+ multiple ?: boolean ;
166
+ name : string ;
167
+ schema : unknown ;
168
+ system : any ;
169
+
170
+ init ( data ? : T ) : void ;
171
+ pause ( ) : void ;
172
+ play ( ) : void ;
173
+ remove ( ) : void ;
174
+ tick ?( time : number , timeDelta : number ) : void ;
175
+ update ( oldData : T ) : void ;
176
+ updateSchema ?( ) : void ;
177
+
178
+ extendSchema ( update : unknown ) : void ;
179
+ flushToDOM ( ) : void ;
180
+ }
181
+
182
+ export interface ComponentConstructor < T extends object > {
183
+ new ( el : unknown , attrValue : string , id : string ) : T & Component ;
184
+ prototype : T & {
185
+ name : string ;
186
+ system : unknown ;
187
+ play ( ) : void ;
188
+ pause ( ) : void ;
189
+ } ;
190
+ }
191
+
192
+ declare function registerComponent < T extends object > (
193
+ name : string ,
194
+ component : ComponentDefinition < T >
195
+ ) : ComponentConstructor < T > ;
196
+
197
+ export type ComponentDefinition < T extends object = object > = T & Partial < Component > & ThisType < T & Component > ;
198
+
199
+ const Component = registerComponent ( 'test-component' , {
200
+ schema : {
201
+ myProperty : {
202
+ default : [ ] ,
203
+ parse ( ) {
204
+ return [ true ] ;
205
+ }
206
+ } ,
207
+ string : { type : 'string' } ,
208
+ num : 0
209
+ } ,
210
+ init ( ) {
211
+ this . data . num = 0 ;
212
+ this . el . setAttribute ( 'custom-attribute' , 'custom-value' ) ;
213
+ } ,
214
+ update ( ) { } ,
215
+ tick ( ) { } ,
216
+ remove ( ) { } ,
217
+ pause ( ) { } ,
218
+ play ( ) { } ,
219
+
220
+ multiply ( f : number ) {
221
+ // Reference to system because both were registered with the same name.
222
+ return f * this . data . num * this . system ! . data . counter ;
223
+ }
224
+ } ) ;
156
225
157
226
158
227
//// [neverReturningFunctions1.js]
159
228
"use strict ";
229
+ exports . __esModule = true ;
160
230
function fail ( message ) {
161
231
throw new Error ( message ) ;
162
232
}
@@ -305,33 +375,61 @@ function f42(x) {
305
375
}
306
376
x ; // Unreachable
307
377
}
378
+ var Component = registerComponent ( 'test-component' , {
379
+ schema : {
380
+ myProperty : {
381
+ "default" : [ ] ,
382
+ parse : function ( ) {
383
+ return [ true ] ;
384
+ }
385
+ } ,
386
+ string : { type : 'string' } ,
387
+ num : 0
388
+ } ,
389
+ init : function ( ) {
390
+ this . data . num = 0 ;
391
+ this . el . setAttribute ( 'custom-attribute' , 'custom-value' ) ;
392
+ } ,
393
+ update : function ( ) { } ,
394
+ tick : function ( ) { } ,
395
+ remove : function ( ) { } ,
396
+ pause : function ( ) { } ,
397
+ play : function ( ) { } ,
398
+ multiply : function ( f ) {
399
+ // Reference to system because both were registered with the same name.
400
+ return f * this . data . num * this . system . data . counter ;
401
+ }
402
+ } ) ;
308
403
309
404
310
405
//// [neverReturningFunctions1.d.ts]
311
- declare function fail ( message ? : string ) : never ;
312
- declare function f01 ( x : string | undefined ) : void ;
313
- declare function f02 ( x : number ) : number ;
314
- declare function f03 ( x : string ) : void ;
315
- declare function f11 ( x : string | undefined , fail : ( message ? : string ) = > never ) : void ;
316
- declare function f12 ( x : number , fail : ( message ? : string ) = > never ) : number ;
317
- declare function f13 ( x : string , fail : ( message ? : string ) = > never ) : void ;
318
- declare namespace Debug {
319
- function fail ( message ? : string ) : never ;
406
+ export interface Component < T extends object = any > {
407
+ attrName ?: string ;
408
+ data : T ;
409
+ dependencies ?: string [ ] ;
410
+ el : any ;
411
+ id : string ;
412
+ multiple ?: boolean ;
413
+ name : string ;
414
+ schema : unknown ;
415
+ system : any ;
416
+ init ( data ? : T ) : void ;
417
+ pause ( ) : void ;
418
+ play ( ) : void ;
419
+ remove ( ) : void ;
420
+ tick ?( time : number , timeDelta : number ) : void ;
421
+ update ( oldData : T ) : void ;
422
+ updateSchema ?( ) : void ;
423
+ extendSchema ( update : unknown ) : void ;
424
+ flushToDOM ( ) : void ;
320
425
}
321
- declare function f21 ( x : string | undefined ) : void ;
322
- declare function f22 ( x : number ) : number ;
323
- declare function f23 ( x : string ) : void ;
324
- declare function f24 ( x : string ) : void ;
325
- declare class Test {
326
- fail ( message ? : string ) : never ;
327
- f1 ( x : string | undefined ) : void ;
328
- f2 ( x : number ) : number ;
329
- f3 ( x : string ) : void ;
426
+ export interface ComponentConstructor < T extends object > {
427
+ new ( el : unknown , attrValue : string , id : string ) : T & Component ;
428
+ prototype : T & {
429
+ name : string ;
430
+ system : unknown ;
431
+ play ( ) : void ;
432
+ pause ( ) : void ;
433
+ } ;
330
434
}
331
- declare function f30 ( x : string | number | undefined ) : void ;
332
- declare function f31 ( x : {
333
- a : string | number ;
334
- } ) : void ;
335
- declare function f40 ( x : number ) : void ;
336
- declare function f41 ( x : number ) : void ;
337
- declare function f42 ( x : number ) : void ;
435
+ export declare type ComponentDefinition < T extends object = object > = T & Partial < Component > & ThisType < T & Component > ;
0 commit comments