ni / nimble

The NI Nimble Design System
https://nimble.ni.dev
MIT License
29 stars 9 forks source link

Evaluate stronger event typing for custom elements #2191

Open rajsite opened 2 weeks ago

rajsite commented 2 weeks ago

🧹 Tech Debt

We override HTMLElementTagNameMap to add definitions for our custom elements like:

declare global {
    interface HTMLElementTagNameMap {
        'nimble-select': Select;
    }
}

It seems possible to also override definitions in HTMLElementEventMap like:

declare global {
    interface HTMLElementEventMap {
        'filter-input': CustomEvent<SelectFilterInputEventDetail>;
    }
}

Which would result in lines like the following having strong typing without any casts:

selectElement.addEventListener('filter-input', evt => evt.detail.filterText);

We should evaluate: