mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
[react-cropper] fix ref prop typing (#34663)
This commit is contained in:
committed by
Armando Aguirre
parent
1717f5656e
commit
dccd225d52
Vendored
+6
-7
@@ -1,19 +1,18 @@
|
||||
// Type definitions for react-cropper 0.10
|
||||
// Project: https://github.com/roadmanfong/react-cropper, http://roadmanfong.github.io/react-cropper
|
||||
// Definitions by: Stepan Mikhaylyuk <https://github.com/stepancar>
|
||||
// Walter Barbagallo <https://github.com/bwlt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as cropperjs from 'cropperjs';
|
||||
import * as React from 'react';
|
||||
|
||||
import Data = cropperjs.Data;
|
||||
import ContainerData = cropperjs.ContainerData;
|
||||
import ImageData = cropperjs.ImageData;
|
||||
import CanvasData = cropperjs.CanvasData;
|
||||
import CropBoxData = cropperjs.CropBoxData;
|
||||
import CroppedCanvasOptions = cropperjs.CroppedCanvasOptions;
|
||||
type ReactCropperProps = cropperjs.CropperOptions & React.HTMLProps<HTMLImageElement>;
|
||||
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export interface ReactCropperProps extends cropperjs.CropperOptions, Omit<React.HTMLProps<HTMLImageElement>, 'data' | 'ref'> {
|
||||
ref: string | ((cropper: null | ReactCropper) => any);
|
||||
}
|
||||
|
||||
interface ReactCropper extends cropperjs {} // tslint:disable-line no-empty-interface
|
||||
declare class ReactCropper extends React.Component<ReactCropperProps> {
|
||||
|
||||
@@ -22,3 +22,18 @@ class Demo extends React.Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function testCropperRef() {
|
||||
<Cropper
|
||||
ref={(el: Cropper) => {
|
||||
// $ExpectError el can be null
|
||||
el.getCroppedCanvas();
|
||||
if (el !== null) {
|
||||
// el is a cropperjs element
|
||||
el.getCroppedCanvas();
|
||||
// el is also a React.Component instance
|
||||
el.props;
|
||||
}
|
||||
}}
|
||||
/>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user