]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: add passive + combinations pikax/capture_jsx_events 9542/head
authorCarlos Rodrigues <carlos@hypermob.co.uk>
Fri, 3 Nov 2023 16:01:56 +0000 (16:01 +0000)
committerCarlos Rodrigues <carlos@hypermob.co.uk>
Fri, 3 Nov 2023 16:01:56 +0000 (16:01 +0000)
packages/dts-test/tsx.test-d.tsx
packages/runtime-dom/src/jsx.ts

index 56f8d2f73bbbeaa80808b2d51c6c74cb3131cc67..3432fdc1f2134bd8229bf17b300d119c5373029c 100644 (file)
@@ -42,6 +42,22 @@ expectType<JSX.Element>(
     onInputCaptureOnce={e => {
       expectType<EventTarget | null>(e.target)
     }}
+    onInputPassive={e => {
+      // infer correct event type
+      expectType<EventTarget | null>(e.target)
+    }}
+    onInputCapturePassive={e => {
+      expectType<EventTarget | null>(e.target)
+    }}
+    onInputOncePassive={e => {
+      expectType<EventTarget | null>(e.target)
+    }}
+    onInputOnceCapturePassive={e => {
+      expectType<EventTarget | null>(e.target)
+    }}
+    onInputPassiveCaptureOnce={e => {
+      expectType<EventTarget | null>(e.target)
+    }}
   />
 )
 
index 3de06672382d98a4074ba8f0b2e76ce43002d055..790e84dc311ae5b588ff1ff66bf8d504c690fb95 100644 (file)
@@ -1351,7 +1351,24 @@ export interface BaseEvents {
   onTransitionstart: TransitionEvent
 }
 
-type EventModifiers = 'Capture' | 'Once' | `OnceCapture` | 'CaptureOnce'
+// All possible combinations, could be generated programmatically but
+// probably too much trouble for little gain, especially it will incur more overhead on the typing
+type EventModifiers =
+  | 'Capture'
+  | 'Once'
+  | 'Passive'
+  | 'CaptureOnce'
+  | 'OnceCapture'
+  | 'CapturePassive'
+  | 'PassiveCapture'
+  | 'OncePassive'
+  | 'PassiveOnce'
+  | 'CaptureOncePassive'
+  | 'CapturePassiveOnce'
+  | 'OnceCapturePassive'
+  | 'OncePassiveCapture'
+  | 'PassiveCaptureOnce'
+  | 'PassiveOnceCapture'
 
 type Events = BaseEvents & {
   [K in keyof BaseEvents as `${K & string}${EventModifiers}`]: BaseEvents[K]