@@ -148,6 +148,18 @@ describe('types', () => {
148148 type : 'button' ;
149149 popovertarget ?: string ;
150150 } > ( ) . toMatchTypeOf < PropsOf < 'input' > > ( ) ;
151+
152+ $ ( ( _ , element ) => {
153+ element . select ( ) ;
154+ expectTypeOf ( element ) . toEqualTypeOf < HTMLInputElement > ( ) ;
155+ } ) as QRLEventHandlerMulti < FocusEvent , HTMLInputElement > ;
156+
157+ const t = $ < EventHandler < FocusEvent , HTMLInputElement > > ( ( _ , element ) => {
158+ element . select ( ) ;
159+ expectTypeOf ( element ) . toEqualTypeOf < HTMLInputElement > ( ) ;
160+ } ) ;
161+ expectTypeOf ( t ) . toExtend < QRLEventHandlerMulti < FocusEvent , HTMLInputElement > > ( ) ;
162+
151163 < >
152164 < button popovertarget = "meep" />
153165 < input type = "button" popovertarget = "meep" />
@@ -225,70 +237,6 @@ describe('types', () => {
225237 </ > ;
226238 } ) ;
227239
228- test ( 'polymorphic component' , ( ) => ( ) => {
229- const Poly = component$ (
230- < C extends string | FunctionComponent = 'div' > ( {
231- as,
232- ...props
233- } : { as ?: C } & PropsOf < string extends C ? 'div' : C > ) => {
234- const Cmp = as || 'div' ;
235- return < Cmp { ...props } > hi</ Cmp > ;
236- }
237- ) ;
238- expectTypeOf < Parameters < typeof Poly < 'button' > > [ 0 ] [ 'popovertarget' ] > ( ) . toEqualTypeOf <
239- string | undefined
240- > ( ) ;
241- expectTypeOf < Parameters < typeof Poly < 'a' > > [ 0 ] [ 'href' ] > ( ) . toEqualTypeOf < string | undefined > ( ) ;
242- expectTypeOf < Parameters < typeof Poly < 'button' > > [ 0 ] > ( ) . not . toHaveProperty ( 'href' ) ;
243- expectTypeOf < Parameters < typeof Poly < 'a' > > [ 0 ] > ( ) . not . toHaveProperty ( 'popovertarget' ) ;
244- expectTypeOf <
245- Parameters < Extract < Parameters < typeof Poly > [ 0 ] [ 'onClick$' ] , EventHandler > > [ 1 ]
246- > ( ) . toEqualTypeOf < HTMLDivElement > ( ) ;
247-
248- const MyCmp = component$ ( ( p : { name : string } ) => < span > Hi { p . name } </ span > ) ;
249-
250- return (
251- < >
252- < Poly
253- onClick$ = { ( ev , el ) => {
254- expectTypeOf ( ev ) . not . toBeAny ( ) ;
255- expectTypeOf ( ev ) . toEqualTypeOf < PointerEvent > ( ) ;
256- expectTypeOf ( el ) . toEqualTypeOf < HTMLDivElement > ( ) ;
257- } }
258- // This should error
259- // popovertarget
260- >
261- Foo
262- </ Poly >
263- < Poly
264- as = "a"
265- onClick$ = { ( ev , el ) => {
266- expectTypeOf ( ev ) . not . toBeAny ( ) ;
267- expectTypeOf ( ev ) . toEqualTypeOf < PointerEvent > ( ) ;
268- expectTypeOf ( el ) . toEqualTypeOf < HTMLAnchorElement > ( ) ;
269- } }
270- href = "hi"
271- // This should error
272- // popovertarget
273- >
274- Foo
275- </ Poly >
276- < Poly
277- as = "button"
278- onClick$ = { ( ev , el ) => {
279- expectTypeOf ( ev ) . not . toBeAny ( ) ;
280- expectTypeOf ( ev ) . toEqualTypeOf < PointerEvent > ( ) ;
281- expectTypeOf ( el ) . toEqualTypeOf < HTMLButtonElement > ( ) ;
282- } }
283- popovertarget = "foo"
284- >
285- Bar
286- </ Poly >
287- < Poly as = { MyCmp } name = "meep" />
288- </ >
289- ) ;
290- } ) ;
291-
292240 test ( 'FunctionComponent' , ( ) => ( ) => {
293241 const Cmp = component$ ( ( props : { foo : string } ) => null ) ;
294242 expectTypeOf ( Cmp ) . toMatchTypeOf < FunctionComponent < { foo : string } > > ( ) ;
0 commit comments