Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 7f5e0c2

Browse files
fix(switch): fix strict generic checks
PiperOrigin-RevId: 291002539 Co-authored-by: Material Web Copybara Robot <[email protected]>
1 parent f2426d2 commit 7f5e0c2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/mdc-switch/component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
import {MDCComponent} from '@material/base/component';
25-
import {EventType} from '@material/base/types';
25+
import {EventType, SpecificEventListener} from '@material/base/types';
2626
import {applyPassive} from '@material/dom/events';
2727
import {matches} from '@material/dom/ponyfill';
2828
import {MDCRippleAdapter} from '@material/ripple/adapter';
@@ -104,15 +104,19 @@ export class MDCSwitch extends MDCComponent<MDCSwitchFoundation> implements MDCR
104104
...MDCRipple.createAdapter(this),
105105
addClass: (className: string) => rippleSurface.classList.add(className),
106106
computeBoundingRect: () => rippleSurface.getBoundingClientRect(),
107-
deregisterInteractionHandler: (evtType: EventType, handler: EventListener) => {
107+
deregisterInteractionHandler: <K extends EventType>(
108+
evtType: K, handler: SpecificEventListener<K>) => {
108109
this.nativeControl_.removeEventListener(evtType, handler, applyPassive());
109110
},
110111
isSurfaceActive: () => matches(this.nativeControl_, ':active'),
111112
isUnbounded: () => true,
112-
registerInteractionHandler: (evtType: EventType, handler: EventListener) => {
113+
registerInteractionHandler: <K extends EventType>(
114+
evtType: K, handler: SpecificEventListener<K>) => {
113115
this.nativeControl_.addEventListener(evtType, handler, applyPassive());
114116
},
115-
removeClass: (className: string) => rippleSurface.classList.remove(className),
117+
removeClass: (className: string) => {
118+
rippleSurface.classList.remove(className);
119+
},
116120
updateCssVariable: (varName: string, value: string) => {
117121
rippleSurface.style.setProperty(varName, value);
118122
},

0 commit comments

Comments
 (0)