Skip to content

Commit

Permalink
Use more complete implementation of Omit in TypeScript definitions (#322
Browse files Browse the repository at this point in the history
)

The previous implementation of the `Omit` type did not support optional and readonly fields, which led to type errors when using the components.
  • Loading branch information
weltenwort authored Jan 26, 2018
1 parent 4dfc7b6 commit f362777
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
**Bug fixes**

- Set `EuiFlexGroup` to `flex-grow: 1` to be more friendly with IE11 [(#315)](https://github.com/elastic/eui/pull/315)
- Fix TypeScript definitions such that optional and readonly properties survive being passed through `Omit` [(#322)](https://github.com/elastic/eui/pull/322)

# [`0.0.13`](https://github.com/elastic/eui/tree/v0.0.13)

Expand Down
2 changes: 1 addition & 1 deletion src/components/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ declare module '@elastic/eui' {
type Diff<T extends string, U extends string> = ({ [P in T]: P } &
{ [P in U]: never } & { [x: string]: never })[T];

type Omit<T, K extends keyof T> = { [P in Diff<keyof T, K>]: T[P] };
type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
}
14 changes: 6 additions & 8 deletions src/components/context_menu/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ declare module '@elastic/eui' {
content?: React.ReactNode;
}

export interface EuiContextMenuProps {
panels?: EuiContextMenuPanelDescriptor[];
initialPanelId?: EuiContextMenuPanelId;
}
export type EuiContextMenuProps = CommonProps &
Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
panels?: EuiContextMenuPanelDescriptor[];
initialPanelId?: EuiContextMenuPanelId;
};

export const EuiContextMenu: SFC<
Omit<HTMLAttributes<HTMLDivElement>, 'className' | 'style'> &
EuiContextMenuProps
>;
export const EuiContextMenu: SFC<EuiContextMenuProps>;
}

0 comments on commit f362777

Please sign in to comment.