We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56a4b77 commit cb3dd6fCopy full SHA for cb3dd6f
index.d.ts
@@ -307,7 +307,7 @@ interface Doctype {
307
readonly systemId: string | null
308
}
309
310
-interface ElementHandler {
+interface ElementHandlerOptionals {
311
/**
312
* An incoming element, such as `div`
313
*/
@@ -322,6 +322,15 @@ interface ElementHandler {
322
text?(text: Text): void
323
324
325
+// See https://stackoverflow.com/a/49725198
326
+type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
327
+ Pick<T, Exclude<keyof T, Keys>>
328
+ & {
329
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>
330
+ }[Keys]
331
+
332
+type ElementHandler = RequireAtLeastOne<ElementHandlerOptionals, 'element' | 'comments' | 'text'>
333
334
interface DocumentHandler {
335
336
* An incoming doctype, such as <!DOCTYPE html>
0 commit comments