cleave.js
cleave.js copied to clipboard
Type definition for `InitHandler` is incorrect causing typescript issues with `onInit` function
In @types/cleave.js/react/props.d.ts InitHandler is defined with type React.ReactInstance
import * as React from "react";
import { CleaveOptions } from "../options";
export type InitHandler = (owner: React.ReactInstance) => void;
export interface ChangeEvent<T> extends React.ChangeEvent<T> {
target: { rawValue: string } & EventTarget & T;
}
export type ChangeEventHandler<T = Element> = React.EventHandler<ChangeEvent<T>>;
export interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
onInit?: InitHandler;
options: CleaveOptions;
htmlRef?: (i: any) => void;
onChange?: ChangeEventHandler<HTMLInputElement>;
}
This is causing a typescript error when trying to access the owner object functions. Can we update the type here so it matches what is expected?
Hi all -- I wanted to see if this is in the works or if perhaps it is not a priority. Thanks in advance!
@tommiewatts @juanfabrega
There is now a PR up in DefinitelyTyped to fix this issue! Not merged yet, but once it is, your problem will be solved.