Skip to content

Commit

Permalink
fix ofType syntax (#2209)
Browse files Browse the repository at this point in the history
  • Loading branch information
giladgray authored and adidahiya committed Mar 7, 2018
1 parent b884410 commit a9ba17c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 16 deletions.
6 changes: 1 addition & 5 deletions packages/core/src/components/tree/tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface ITreeProps<T = {}> extends IProps {

export class Tree<T = {}> extends React.Component<ITreeProps<T>, {}> {
public static ofType<T>() {
return Tree as new () => Tree<T>;
return Tree as new (props: ITreeProps<T>) => Tree<T>;
}

public static nodeFromPath(path: number[], treeNodes: ITreeNode[]): ITreeNode {
Expand All @@ -63,10 +63,6 @@ export class Tree<T = {}> extends React.Component<ITreeProps<T>, {}> {

private nodeRefs: { [nodeId: string]: HTMLElement } = {};

constructor(props?: ITreeProps<T>, context?: any) {
super(props, context);
}

public render() {
return (
<div className={classNames(Classes.TREE, this.props.className)}>
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/components/tree/treeNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ export interface ITreeNodeProps<T = {}> extends ITreeNode<T> {

export class TreeNode<T = {}> extends React.Component<ITreeNodeProps<T>, {}> {
public static ofType<T>() {
return TreeNode as new () => TreeNode<T>;
}

constructor(props?: ITreeNodeProps<T>, context?: any) {
super(props, context);
return TreeNode as new (props: ITreeNodeProps<T>) => TreeNode<T>;
}

public render() {
Expand Down
3 changes: 3 additions & 0 deletions packages/datetime/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Should only be used if measuring can't be done with existing DOM elements.
*/
export function measureTextWidth(text: string, className = "", containerElement = document.body) {
if (containerElement == null) {
return 0;
}
const span = document.createElement("span");
span.classList.add(className);
span.textContent = text;
Expand Down
2 changes: 1 addition & 1 deletion packages/datetime/test/dateRangePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("<DateRangePicker>", () => {
before(() => {
// this is essentially what TestUtils.renderIntoDocument does
testsContainerElement = document.createElement("div");
document.documentElement.appendChild(testsContainerElement);
document.body.appendChild(testsContainerElement);
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/components/omnibar/omnibar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Omnibar<T> extends React.PureComponent<IOmnibarProps<T>, IOmnibarSt
public static displayName = "Blueprint2.Omnibar";

public static ofType<T>() {
return (Omnibar as any) as new () => Omnibar<T>;
return Omnibar as new (props: IOmnibarProps<T>) => Omnibar<T>;
}

public state: IOmnibarState<T> = {
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/components/select/multiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class MultiSelect<T> extends React.PureComponent<IMultiSelectProps<T>, IM
public static displayName = "Blueprint2.MultiSelect";

public static ofType<T>() {
return (MultiSelect as any) as new () => MultiSelect<T>;
return MultiSelect as new (props: IMultiSelectProps<T>) => MultiSelect<T>;
}

public state: IMultiSelectState<T> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/select/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class Select<T> extends React.PureComponent<ISelectProps<T>, ISelectState
public static displayName = "Blueprint2.Select";

public static ofType<T>() {
return Select as new () => Select<T>;
return Select as new (props: ISelectProps<T>) => Select<T>;
}

public state: ISelectState<T> = { isOpen: false, query: "" };
Expand All @@ -107,7 +107,7 @@ export class Select<T> extends React.PureComponent<ISelectProps<T>, ISelectState
};
private previousFocusedElement: HTMLElement;

constructor(props?: ISelectProps<T>, context?: any) {
constructor(props: ISelectProps<T>, context?: any) {
super(props, context);

const query = props && props.inputProps && props.inputProps.value !== undefined ? props.inputProps.value : "";
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/components/select/suggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Suggest<T> extends React.PureComponent<ISuggestProps<T>, ISuggestSt
public static displayName = "Blueprint2.Suggest";

public static ofType<T>() {
return (Suggest as any) as new () => Suggest<T>;
return Suggest as new (props: ISuggestProps<T>) => Suggest<T>;
}

public state: ISuggestState<T> = {
Expand Down

1 comment on commit a9ba17c

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix ofType syntax (#2209)

Preview: documentation | landing | table

Please sign in to comment.