Skip to content

Commit

Permalink
Merge pull request #477 from wellyshen/feature/enhance-types
Browse files Browse the repository at this point in the history
Refactor(types): enhance the types of event properties
  • Loading branch information
wellyshen authored May 19, 2021
2 parents 6cab7a7 + 1c1146e commit 3268932
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ export const borderBoxWarn =
"💡 react-cool-dimensions: the browser doesn't support border-box size, fallback to content-box size. Please see: https://github.com/wellyshen/react-cool-dimensions#border-box-size-measurement";

interface State {
currentBreakpoint: string;
width: number;
height: number;
entry?: ResizeObserverEntry;
readonly currentBreakpoint: string;
readonly width: number;
readonly height: number;
readonly entry?: ResizeObserverEntry;
}
interface Observe<T> {
(element?: T | null): void;
}
interface Event<T> extends State {
entry: ResizeObserverEntry;
readonly entry: ResizeObserverEntry;
observe: Observe<T>;
unobserve: () => void;
}
Expand Down
20 changes: 10 additions & 10 deletions src/react-cool-dimensions.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
declare module "react-cool-dimensions" {
// Types from @types/resize-observer-browser
interface ResizeObserverSize {
inlineSize: number;
blockSize: number;
readonly inlineSize: number;
readonly blockSize: number;
}

interface ResizeObserverEntry {
Expand All @@ -14,19 +14,19 @@ declare module "react-cool-dimensions" {

// Hook types
export interface Event<T extends HTMLElement | null = HTMLElement> {
currentBreakpoint: string;
width: number;
height: number;
entry: ResizeObserverEntry;
readonly currentBreakpoint: string;
readonly width: number;
readonly height: number;
readonly entry: ResizeObserverEntry;
observe: (element?: T | null) => void;
unobserve: () => void;
}

export interface State {
currentBreakpoint: string;
width: number;
height: number;
entry?: ResizeObserverEntry;
readonly currentBreakpoint: string;
readonly width: number;
readonly height: number;
readonly entry?: ResizeObserverEntry;
}

export interface ShouldUpdate {
Expand Down

0 comments on commit 3268932

Please sign in to comment.