Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update react-sizeme.d.ts #171

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions react-sizeme.d.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
import { Component, ComponentType, ReactNode, ReactElement } from 'react'

type Omit<T, K> = Pick<T, Exclude<keyof T, K>>
declare namespace sizeMe {
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>

export interface SizeMeProps {
size: {
width: number | null
height: number | null
export interface SizeMeProps {
size: {
width: number | null
height: number | null
}
}
}

export interface SizeMeOptions {
monitorWidth?: boolean
monitorHeight?: boolean
monitorPosition?: boolean
refreshRate?: number
refreshMode?: 'throttle' | 'debounce'
noPlaceholder?: boolean
}

export interface SizeMeRenderProps extends SizeMeOptions {
children: (props: SizeMeProps) => ReactElement
}
export interface SizeMeOptions {
monitorWidth?: boolean
monitorHeight?: boolean
monitorPosition?: boolean
refreshRate?: number
refreshMode?: 'throttle' | 'debounce'
noPlaceholder?: boolean
}

export class SizeMe extends Component<SizeMeRenderProps> {}
export interface SizeMeRenderProps extends SizeMeOptions {
children: (props: SizeMeProps) => ReactElement
}
export class SizeMe extends Component<SizeMeRenderProps> {}

export const withSize: (
options?: SizeMeOptions,
) => <P extends object = {}>(
export const withSize: (
options?: SizeMeOptions,
) => <P extends object = {}>(
component: ComponentType<P>,
) => ComponentType<Omit<P, 'size'>>
}
declare function sizeMe(
options?: sizeMe.SizeMeOptions,
): <P extends object = {}>(
component: ComponentType<P>,
) => ComponentType<Omit<P, 'size'>>
) => ComponentType<sizeMe.Omit<P, 'size'>>

export = sizeMe