UNPKG

1.23 kBTypeScriptView Raw
1declare type anyFunc = (...a: any[]) => any;
2declare type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
3declare type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
4export declare function prepareInterceptor<ElementType extends Element, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {
5 /**
6 * React tracks the changes on element properties.
7 * This workaround tries to alter the DOM element without React noticing,
8 * so that it later picks up the change.
9 *
10 * @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
11 */
12 applyNative?: boolean;
13 realArgs?: ImplReturn<ElementType[PropName]>;
14 then?: () => void;
15}): void;
16export declare function prepareValueInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
17export declare function prepareSelectionInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
18export declare function prepareRangeTextInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
19export {};