lovasoa / react-contenteditable

React component for a div with editable contents
http://npmjs.com/package/react-contenteditable
Apache License 2.0
1.63k stars 218 forks source link

Typescript error on 3.7.5 #192

Open Anahkiasen opened 4 years ago

Anahkiasen commented 4 years ago

When I try to use the ContentEditable component with Typescript 3.7.5 I get the following error:

No overload matches this call.
  Overload 1 of 2, '(props: Readonly<Props>): ContentEditable', gave the following error.
    Property 'onChange' is missing in type '{ innerRef: RefObject<HTMLSpanElement>; className: string; tagName: string; html: string; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "ref" | "html" | "style" | "title" | "className" | "children" | "defaultChecked" | ... 251 more ... | "key">'.
  Overload 2 of 2, '(props: Props, context?: any): ContentEditable', gave the following error.
    Property 'onChange' is missing in type '{ innerRef: RefObject<HTMLSpanElement>; className: string; tagName: string; html: string; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "ref" | "html" | "style" | "title" | "className" | "children" | "defaultChecked" | ... 251 more ... | "key">'.  TS2769

Whether I specify onChange doesn't seem to do anything, this seems to be an issue with the use of Modify and DivProps where TS is basically saying you can't add an onChange to a div or something, not sure

f0rmat1k commented 4 years ago

I also have errors in typings:

onScroll?: ((event: React.UIEvent<HTMLDivElement, UIEvent>) => void) | undefined;
onScrollCapture?: ((event: React.UIEvent<HTMLDivElement, UIEvent>) => void) | undefined;

TS2707: Generic type 'UIEvent' requires between 0 and 1 type arguments.

UIEvent has such interface:

interface UIEvent<T = Element> extends SyntheticEvent<T, NativeUIEvent> {
        detail: number;
        view: AbstractView;
    }