diff --git a/typings/carouselElements.d.ts b/typings/carouselElements.d.ts index d18f259..c3e2478 100644 --- a/typings/carouselElements.d.ts +++ b/typings/carouselElements.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react' +import React from 'react' interface SliderProps extends React.HTMLAttributes { readonly children: React.ReactNode @@ -13,7 +13,7 @@ interface SliderProps extends React.HTMLAttributes { readonly trayTag?: string readonly trayProps?: React.HTMLAttributes } -type SliderInterface = React.ComponentClass +type SliderInterface = React.ComponentType /** * A Slider is a viewport that masks slides. The Slider component must wrap one or more Slide components. */ @@ -34,7 +34,7 @@ interface SlideProps extends React.HTMLAttributes { readonly tag?: string readonly style?: {} } -type SlideInterface = React.ComponentClass +type SlideInterface = React.ComponentType /** * The Slide component is a container with an intrinsic ratio computed by the * CarouselProvider naturalSlideWidth and naturalSlideHeight properties. @@ -59,7 +59,7 @@ interface ImageWithZoomProps { readonly tag?: string readonly isPinchZoomEnabled?: boolean } -type ImageWithZoomInterface = React.ComponentClass +type ImageWithZoomInterface = React.ComponentType declare const ImageWithZoom: ImageWithZoomInterface diff --git a/typings/index.d.ts b/typings/index.d.ts index 75968dc..944ee10 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2,7 +2,7 @@ // Definitions by: Jedrzej Lewandowski // TypeScript Version: 2.7.2 -import * as React from 'react' +import React from 'react' import { ButtonBack, ButtonFirst, @@ -26,7 +26,7 @@ import { ButtonLastProps, ButtonFirstProps, ButtonPlayProps -} from './carouselElements.d' +} from './carouselElements' interface CarouselState { readonly currentSlide: number @@ -97,7 +97,7 @@ interface CarouselProviderProps { readonly isIntrinsicHeight?: CarouselState['isIntrinsicHeight'] } -type CarouselProviderInterface = React.ComponentClass +type CarouselProviderInterface = React.ComponentType /** * CarouselProvider allows the other carousel components to communicate with each other. * @@ -115,31 +115,25 @@ type CarouselProviderInterface = React.ComponentClass declare const CarouselProvider: CarouselProviderInterface export interface CarouselInjectedProps { - readonly carouselStore: CarouselStoreInterface + readonly carouselStore: Pick< + CarouselStoreInterface, + | "getStoreState" + | "masterSpinnerError" + | "masterSpinnerSuccess" + | "setStoreState" + | "subscribeMasterSpinner" + | "unsubscribeAllMasterSpinner" + | "unsubscribeMasterSpinner" + >; } -// Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 -type Diff = ({ [P in T]: P } & - { [P in U]: never } & { readonly [x: string]: never })[T] -type Omit = Pick, Extract>> - type MapStateToProps = (state: CarouselState) => TStateProps interface WithStoreInterface { - ( - component: React.ComponentClass - ): React.ComponentClass> & { - readonly WrappedComponent: React.ComponentClass - } - - ( - component: React.ComponentClass, - state: MapStateToProps - ): React.ComponentClass> & { - readonly WrappedComponent: React.ComponentClass< - CustomProps & CustomStateProps - > - } + ( + component: React.ComponentType, + mapStateToProps?: MapStateToProps + ): React.ComponentType } /** * Use this HOC to pass CarouselProvider state properties as props to a component.