Skip to content

Commit

Permalink
simplified typing of createIcon return type
Browse files Browse the repository at this point in the history
  • Loading branch information
telamonian committed Oct 7, 2019
1 parent aab6d7d commit d45419a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions packages/ui-components/src/icon/jlicon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function createIcon(
}
}

const _JLIcon = React.forwardRef(
const JLIcon: JLIcon.IComponent = React.forwardRef(
(props: JLIcon.IProps, ref: React.RefObject<HTMLDivElement>) => {
const { className, title, tag = 'div', ...propsStyle } = props;
const Tag = tag;
Expand All @@ -59,11 +59,6 @@ export function createIcon(
}
);

// widen type to include .element
let JLIcon: typeof _JLIcon & {
element: (props: JLIcon.IProps) => HTMLElement;
} = _JLIcon as any;

JLIcon.element = ({
className,
title,
Expand Down Expand Up @@ -116,9 +111,12 @@ export namespace JLIcon {
}

/**
* The state for a JLIcon component
* The type of the react component-like object that gets
* returned by createIcon
*/
export interface IState {}
export interface IComponent extends ReturnType<typeof React.forwardRef> {
element?: (props: IProps) => HTMLElement;
}
}

namespace Private {
Expand All @@ -134,9 +132,3 @@ namespace Private {
}
}
}

// import notTrustedSvg from '../../style/icons/statusbar/not-trusted.svg';
// import trustedSvg from '../../style/icons/statusbar/trusted.svg';
//
// export const NotTrustedIcon = createIcon('notTrusted', notTrustedSvg);
// export const TrustedIcon = createIcon('trusted', trustedSvg);

0 comments on commit d45419a

Please sign in to comment.