Skip to content

Commit 0462e35

Browse files
committed
fix: types for overload of SelectorObserver constructor
1 parent f223ee2 commit 0462e35

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/stupid-pants-relax.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sv443-network/userutils": patch
3+
---
4+
5+
Fixed TS types for overload of SelectorObserver constructor

lib/SelectorObserver.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export type SelectorObserverOptions = {
3131
enableOnAddListener?: boolean;
3232
};
3333

34+
export type SelectorObserverConstructorOptions = MutationObserverInit & SelectorObserverOptions;
35+
3436
/** Observes the children of the given element for changes */
3537
export class SelectorObserver {
3638
private enabled = false;
@@ -45,14 +47,14 @@ export class SelectorObserver {
4547
* @param baseElementSelector The selector of the element to observe
4648
* @param options Fine-tune what triggers the MutationObserver's checking function - `subtree` and `childList` are set to true by default
4749
*/
48-
constructor(baseElementSelector: string, options?: SelectorObserverOptions & MutationObserverInit)
50+
constructor(baseElementSelector: string, options?: SelectorObserverConstructorOptions)
4951
/**
5052
* Creates a new SelectorObserver that will observe the children of the given base element for changes (only creation and deletion of elements by default)
5153
* @param baseElement The element to observe
5254
* @param options Fine-tune what triggers the MutationObserver's checking function - `subtree` and `childList` are set to true by default
5355
*/
54-
constructor(baseElement: Element, options?: SelectorObserverOptions)
55-
constructor(baseElement: Element | string, options: SelectorObserverOptions = {}) {
56+
constructor(baseElement: Element, options?: SelectorObserverConstructorOptions)
57+
constructor(baseElement: Element | string, options: SelectorObserverConstructorOptions = {}) {
5658
this.baseElement = baseElement;
5759

5860
this.listenerMap = new Map<string, SelectorListenerOptions[]>();

0 commit comments

Comments
 (0)