File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed
tests/cases/conformance/controlFlow Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -156,3 +156,72 @@ function f42(x: number) {
156156 }
157157 x ; // Unreachable
158158}
159+
160+ // Repro from #33582
161+
162+ export interface Component < T extends object = any > {
163+ attrName ?: string ;
164+ data : T ;
165+ dependencies ?: string [ ] ;
166+ el : any ;
167+ id : string ;
168+ multiple ?: boolean ;
169+ name : string ;
170+ schema : unknown ;
171+ system : any ;
172+
173+ init ( data ?: T ) : void ;
174+ pause ( ) : void ;
175+ play ( ) : void ;
176+ remove ( ) : void ;
177+ tick ?( time : number , timeDelta : number ) : void ;
178+ update ( oldData : T ) : void ;
179+ updateSchema ?( ) : void ;
180+
181+ extendSchema ( update : unknown ) : void ;
182+ flushToDOM ( ) : void ;
183+ }
184+
185+ export interface ComponentConstructor < T extends object > {
186+ new ( el : unknown , attrValue : string , id : string ) : T & Component ;
187+ prototype : T & {
188+ name : string ;
189+ system : unknown ;
190+ play ( ) : void ;
191+ pause ( ) : void ;
192+ } ;
193+ }
194+
195+ declare function registerComponent < T extends object > (
196+ name : string ,
197+ component : ComponentDefinition < T >
198+ ) : ComponentConstructor < T > ;
199+
200+ export type ComponentDefinition < T extends object = object > = T & Partial < Component > & ThisType < T & Component > ;
201+
202+ const Component = registerComponent ( 'test-component' , {
203+ schema : {
204+ myProperty : {
205+ default : [ ] ,
206+ parse ( ) {
207+ return [ true ] ;
208+ }
209+ } ,
210+ string : { type : 'string' } ,
211+ num : 0
212+ } ,
213+ init ( ) {
214+ this . data . num = 0 ;
215+ this . el . setAttribute ( 'custom-attribute' , 'custom-value' ) ;
216+ } ,
217+ update ( ) { } ,
218+ tick ( ) { } ,
219+ remove ( ) { } ,
220+ pause ( ) { } ,
221+ play ( ) { } ,
222+
223+ multiply ( f : number ) {
224+ // Reference to system because both were registered with the same name.
225+ return f * this . data . num * this . system ! . data . counter ;
226+ }
227+ } ) ;
You can’t perform that action at this time.
0 commit comments