-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeScript] Add StaticDataTable type definition (#8878)
This adds a typescript module definition for StaticDataTable, so that it can be imported from typescript in strict mode without triggering errors. It also adds a new parameter to the "getFormattedColumn" callback to indicate the current index of the column. (This should technically be a different PR, but it's easier to do it at the same time rather than need to modify the definition after.)
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {ReactNode} from 'react'; | ||
/** | ||
* This file contains a sufficient typescript definition of the StaticDataTable | ||
* to allow it to be imported into TypeScript with "strict" mode and not trigger | ||
* errors. | ||
*/ | ||
|
||
type TableRow = (string|null)[]; | ||
|
||
type StaticDataTableProps = { | ||
Headers: string[], | ||
Data: TableRow[], | ||
RowNumLabel: string?, | ||
getFormattedCell: ( | ||
columnname: string, | ||
celldata: string, | ||
row: string[], | ||
headers: string[], | ||
fieldNo: number | ||
) => ReactNode, | ||
onSort?: () => void | ||
}; | ||
|
||
/** | ||
* StaticDataTable class. See StaticDataTable.js | ||
*/ | ||
class StaticDataTable { | ||
props: StaticDataTableProps | ||
state: any | ||
context: object | ||
refs: {[key: string]: ReactInstance} | ||
|
||
/** | ||
* Create a StaticDataTable | ||
* | ||
* @param {StaticDataTableProps} props - React props | ||
*/ | ||
constructor(props: StaticDataTableProps) | ||
|
||
/** | ||
* React Lifecycle Method | ||
* | ||
* @returns {ReactNode} - the StaticDataTable | ||
*/ | ||
render(): ReactNode | ||
|
||
/** | ||
* React Lifecycle Method | ||
* | ||
* @param {object} newstate - the state to overwrite | ||
*/ | ||
setState(newstate: object): void | ||
|
||
/** | ||
* React Lifecycle Method | ||
*/ | ||
forceUpdate(): void | ||
} | ||
|
||
export default StaticDataTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters