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

Improve typescript definitions #525

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/components/accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ interface AccordionProps {
onTabChange?(e: {originalEvent: Event, index: number}): void;
}

export class Accordion extends React.Component<AccordionProps,any> {}
// tslint:disable-next-line:max-classes-per-file
export class Accordion extends React.Component<AccordionProps,any> {}

4 changes: 2 additions & 2 deletions src/components/autocomplete/AutoComplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface AutoCompleteProps {
id?: string;
value?: any;
name?: string;
suggestions?: Array<any>;
suggestions?: any[];
field?: string;
scrollHeight?: string;
dropdown?: boolean;
Expand Down Expand Up @@ -42,4 +42,4 @@ interface AutoCompleteProps {
onClear?(event:Event): void;
}

export class AutoComplete extends React.Component<AutoCompleteProps,any> {}
export class AutoComplete extends React.Component<AutoCompleteProps,any> {}
4 changes: 2 additions & 2 deletions src/components/breadcrumb/BreadCrumb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {MenuItem} from '../menuitem/MenuItem';

interface BreadCrumbProps {
id?: string;
model?: Array<MenuItem>;
model?: MenuItem[];
home?: any;
style?: object;
className?: string;
}

export class BreadCrumb extends React.Component<BreadCrumbProps,any> {}
export class BreadCrumb extends React.Component<BreadCrumbProps,any> {}
5 changes: 3 additions & 2 deletions src/components/button/Button.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React = require("react");
import {Omit} from "../util";

interface ButtonProps extends React.HTMLProps<HTMLButtonElement> {
interface ButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'ref'> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is tricky. React.HTMLProps<HTMLButtonElement> already has a ref-prop which exposes the HTMLButtonElement. However Button (as every component) has its own ref. Those definitions now clash, so I removed it from the inherited props type. Also, the ref is now for the Button instance, not the DOM element. So if you need to expose the native element, there are two solutions: either have an extra prop that is passed to the DOM element (e.g. nativeRef) or consider using forward refs (https://reactjs.org/docs/forwarding-refs.html#forwarding-refs-to-dom-components).

This change was necessary for the DataScroller demo.

label?: string;
icon?: string;
iconPos?: string;
cornerStyleClass?: string;
[key: string]: any;
}

export class Button extends React.Component<ButtonProps,any> {}
export class Button extends React.Component<ButtonProps,any> {}
5 changes: 3 additions & 2 deletions src/components/calendar/Calendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ interface CalendarProps {
autoZIndex?: boolean;
baseZIndex?: number;
appendTo?: any;
dateTemplate?(dateMeta:DateMetaData): JSX.Element | undefined;
yearRange?: string;
dateTemplate?(dateMeta:DateMetaData): React.ReactNode;
onFocus?(event: Event): void;
onBlur?(event: Event): void;
onInput?(event: Event): void;
Expand All @@ -82,4 +83,4 @@ interface CalendarProps {
onViewDateChange?(e: {originalEvent: Event, value: Date}): void;
}

export class Calendar extends React.Component<CalendarProps,any> {}
export class Calendar extends React.Component<CalendarProps,any> {}
4 changes: 2 additions & 2 deletions src/components/checkbox/Checkbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface CheckboxProps {
inputId?: string;
value?: any;
name?: string;
checked: boolean;
checked?: boolean;
style?: object;
className?: string;
disabled?: boolean;
Expand All @@ -15,4 +15,4 @@ interface CheckboxProps {
onChange(e: { originalEvent: Event, value: any, checked: boolean}): void;
}

export class Checkbox extends React.Component<CheckboxProps,any> {}
export class Checkbox extends React.Component<CheckboxProps,any> {}
4 changes: 2 additions & 2 deletions src/components/chips/Chips.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface ChipsProps {
id?: string;
name?: string;
placeholder?: string;
value?: Array<any>;
value?: any[];
max?: number;
disabled?: boolean;
style?: object;
Expand All @@ -15,4 +15,4 @@ interface ChipsProps {
onChange?(e: {originalEvent: Event, value: any}): void;
}

export class Chips extends React.Component<ChipsProps,any> {}
export class Chips extends React.Component<ChipsProps,any> {}
10 changes: 5 additions & 5 deletions src/components/column/Column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ interface ColumnProps {
body?: any;
footer?: any;
sortable?: boolean;
sortFunction?(): void;
filter?: boolean;
filterMatchMode?: string;
filterPlaceholder?: string;
filterType?: string;
filterMaxLength?: number;
filterElement?: object;
filterFunction?(value: any, filter: any): void;
style?: object;
className?: string;
headerStyle?: object;
Expand All @@ -29,10 +27,12 @@ interface ColumnProps {
selectionMode?: string;
colSpan?: number;
rowSpan?: number;
editor?(props: any): JSX.Element | undefined;
editorValidator?(props: any): boolean;
rowReorder?: boolean;
rowReorderIcon?: string;
sortFunction?(): void;
filterFunction?(value: any, filter: any): void;
editor?(props: any): JSX.Element | undefined;
editorValidator?(props: any): boolean;
}

export class Column extends React.Component<ColumnProps,any> {}
export class Column extends React.Component<ColumnProps,any> {}
3 changes: 2 additions & 1 deletion src/components/columngroup/ColumnGroup.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React = require("react");

// tslint:disable-next-line:no-empty-interface
interface ColumnGroupProps {
}

export class ColumnGroup extends React.Component<ColumnGroupProps,any> {}
export class ColumnGroup extends React.Component<ColumnGroupProps,any> {}
7 changes: 5 additions & 2 deletions src/components/contextmenu/ContextMenu.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React = require("react");
import {MenuItem} from '../menuitem/MenuItem';
import {SyntheticEvent} from "react";

interface ContextMenuProps {
id?: string;
model?: Array<MenuItem>;
model?: MenuItem[];
style?: object;
className?: string;
global?: boolean;
Expand All @@ -14,4 +15,6 @@ interface ContextMenuProps {
onHide?(e: Event): void;
}

export class ContextMenu extends React.Component<ContextMenuProps,any> {}
export class ContextMenu extends React.Component<ContextMenuProps,any> {
public show(event:SyntheticEvent):void;
}
10 changes: 5 additions & 5 deletions src/components/datagrid/DataGrid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import React = require("react");

interface DataGridProps {
id?: string,
value?: Array<any>,
value?: any[],
rows?: number,
first?:number,
paginator?: boolean,
totalRecords?: number,
pageLinks?: number,
rowsPerPageOptions?: Array<any>,
rowsPerPageOptions?: any[],
lazy?: boolean,
style?: string,
className?: string,
paginatorPosition?: string,
paginatorTemplate?: string,
onLazyLoad?(e: {first: number, rows:number}): void,
itemTemplate?(item: any): JSX.Element | undefined,
header?:string,
footer?:string;
onLazyLoad?(e: {first: number, rows:number}): void,
itemTemplate?(item: any): JSX.Element | undefined,
}

export class DataGrid extends React.Component<DataGridProps,any> {}
export class DataGrid extends React.Component<DataGridProps,any> {}
10 changes: 5 additions & 5 deletions src/components/datalist/DataList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import React = require("react");

interface DataListProps {
id?: string;
value?: Array<any>;
value?: any[];
rows?: number;
first?:number;
paginator?: boolean;
totalRecords?: number;
pageLinks?: number;
rowsPerPageOptions?: Array<any>;
rowsPerPageOptions?: any[];
lazy?: boolean;
style?: object;
className?: string;
paginatorPosition?: string;
paginatorTemplate?: string;
onLazyLoad?({first: number, rows:number}): void;
itemTemplate?(item: any): JSX.Element | undefined;
header?:string;
footer?:string;
onLazyLoad?(e: {first: number, rows:number}): void;
itemTemplate?(item: any): JSX.Element | undefined;
}

export class DataList extends React.Component<DataListProps,any> {}
export class DataList extends React.Component<DataListProps,any> {}
8 changes: 4 additions & 4 deletions src/components/datascroller/DataScroller.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import React = require("react");

interface DataScrollerProps {
id?: string;
value?: Array<any>;
value?: any[];
rows?: number;
inline?: boolean;
scrollHeight?: any;
loader?: any;
buffer?: number;
style?: object;
className?: string;
onLazyLoad?(e: {first: number, rows: number}): void;
itemTemplate?(item: any): JSX.Element | undefined;
header?: any;
footer?: any;
lazy?: boolean;
onLazyLoad?(e: {first: number, rows: number}): void;
itemTemplate?(item: any): JSX.Element | undefined;
}

export class DataScroller extends React.Component<DataScrollerProps,any> {}
export class DataScroller extends React.Component<DataScrollerProps,any> {}
3 changes: 2 additions & 1 deletion src/components/datatable/BodyCell.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React = require("react");

// tslint:disable-next-line:no-empty-interface
interface BodyCellProps {
}

export class BodyCell extends React.Component<BodyCellProps,any> {}
export class BodyCell extends React.Component<BodyCellProps,any> {}
3 changes: 2 additions & 1 deletion src/components/datatable/BodyRow.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React = require("react");

// tslint:disable-next-line:no-empty-interface
interface BodyRowProps {
}

export class BodyRow extends React.Component<BodyRowProps,any> {}
export class BodyRow extends React.Component<BodyRowProps,any> {}
28 changes: 16 additions & 12 deletions src/components/datatable/DataTable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React = require("react");

interface DataTableProps {
id?: string;
value?: Array<any>;
value?: any[];
header?: any;
footer?: any;
style?: object;
Expand All @@ -23,22 +23,19 @@ interface DataTableProps {
lazy?: boolean;
sortField?: string;
sortOrder?: number;
multiSortMeta?: Array<any>;
multiSortMeta?: any[];
sortMode?: string;
emptyMessage?: string;
selectionMode?: string;
selection?: any;
onSelectionChange?(e: {originalEvent: Event, data: any}): void;
compareSelectionBy?: string;
dataKey?: string;
metaKeySelection?: boolean;
headerColumnGroup?: JSX.Element;
footerColumnGroup?: JSX.Element;
frozenHeaderColumnGroup?: JSX.Element;
frozenFooterColumnGroup?: JSX.Element;
rowExpansionTemplate?(data: any): JSX.Element | undefined;
expandedRows?: Array<any>;
onRowToggle?(data: Array<any>): void;
expandedRows?: any[];
responsive?: boolean;
resizableColumns?: boolean;
columnResizeMode?: string;
Expand All @@ -51,21 +48,25 @@ interface DataTableProps {
virtualScrollDelay?: number;
frozenWidth?: string;
unfrozenWidth?: string;
frozenValue?: Array<any>;
frozenValue?: any[];
csvSeparator?: string;
exportFilename?: string;
contextMenu?: any;
rowGroupMode?: string;
autoLayout?:boolean;
rowClassName?(rowData: any): object;
rowGroupHeaderTemplate?(data: any, index: number): JSX.Element | undefined;
rowGroupFooterTemplate?(data: any, index: number): JSX.Element | undefined;
loading?:boolean;
loadingIcon?:string;
groupField?:string;
onSelectionChange?(e: {originalEvent: Event, data: any}): void;
rowExpansionTemplate?(data: any): JSX.Element | undefined;
onRowToggle?(e: {data: any[]}): void;
rowClassName?(rowData: any): object;
rowGroupHeaderTemplate?(data: any, index: number): React.ReactNode | undefined;
rowGroupFooterTemplate?(data: any, index: number): React.ReactNode | undefined;
onColumnResizeEnd?(e: {element: HTMLElement, delta: number}): void;
onSort?(e: {sortField: string, sortOrder: number, multiSortMeta: any}): void;
onPage?(e: {first: number, rows: number}): void;
onFilter?(filters: Array<any>): void;
onFilter?(filters: any[]): void;
onVirtualScroll?(e: {first: number, rows: number}): void;
onRowClick?(e: Event): void;
onRowDoubleClick?(e: {originalEvent: Event, data: any, index: number}): void;
Expand All @@ -78,4 +79,7 @@ interface DataTableProps {
onRowReorder?(e: {originalEvent: Event, value: any, dragIndex: number, dropIndex: number}): void;
}

export class DataTable extends React.Component<DataTableProps,any> {}
export class DataTable extends React.Component<DataTableProps,any> {
public exportCSV():void;
public filter<T>(value:T, field:string, mode:string):void;
}
3 changes: 2 additions & 1 deletion src/components/datatable/FooterCell.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React = require("react");

// tslint:disable-next-line:no-empty-interface
interface FooterCellProps {
}

export class FooterCell extends React.Component<FooterCellProps,any> {}
export class FooterCell extends React.Component<FooterCellProps,any> {}
3 changes: 2 additions & 1 deletion src/components/datatable/HeaderCell.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React = require("react");

// tslint:disable-next-line:no-empty-interface
interface HeaderCellProps {
}

export class HeaderCell extends React.Component<HeaderCellProps,any> {}
export class HeaderCell extends React.Component<HeaderCellProps,any> {}
4 changes: 2 additions & 2 deletions src/components/datatable/RowRadioButton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React = require("react");

interface RowRadioButtonProps {
rowData?: object;
onClick?(e: {originalEvent: Event, data: object}): void;
selected?: boolean;
onClick?(e: {originalEvent: Event, data: object}): void;
}

export class RowRadioButton extends React.Component<RowRadioButtonProps,any> {}
export class RowRadioButton extends React.Component<RowRadioButtonProps,any> {}
3 changes: 2 additions & 1 deletion src/components/datatable/TableBody.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React = require("react");

// tslint:disable-next-line:no-empty-interface
interface TableBodyProps {
}

export class TableBody extends React.Component<TableBodyProps,any> {}
export class TableBody extends React.Component<TableBodyProps,any> {}
3 changes: 2 additions & 1 deletion src/components/datatable/TableFooter.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React = require("react");

// tslint:disable-next-line:no-empty-interface
interface TableFooterProps {
}

export class TableFooter extends React.Component<TableFooterProps,any> {}
export class TableFooter extends React.Component<TableFooterProps,any> {}
Loading