Fix and tidy TSDoc comments

Correct the constructor summary, replace stale R references with TRow,
fix {@link Header<TRow>} to {@link Header}, and fix assorted typos.
This commit is contained in:
CentreMetre
2026-06-14 18:06:44 +01:00
parent 8d8107ec49
commit 4e5428eee2

View File

@@ -17,18 +17,18 @@ export abstract class Table<TRow extends Object> {
messageEl: HTMLElement | null;
/**
* Creates a list of Header objects to be used in a table for the header cell values and column types.
* Constructs a table based on the parameters given.
* @param exampleObject An instance of the type to be displaying. Can be an object with default/zero values for that type
* such as `0`, `""`, `false` or `true`. E.g. for a user ```{ id: 0; name: ""; }``` would be passed
* @param displayNamesAndOrder A object with the same properties, but all string type for the header cell values.
* Used by passing an object with the keys of R and the name preferred. E.g. for a user:
* Used by passing an object with the keys of {@link TRow} and the name preferred. E.g. for a user:
* ```{ id: "ID", name: "Name" }```, this makes the columns appear in the order of ID then Name.
* @param messageElement Used to display messaged related to data output. Optional.
* @param messageElement Used to display messages related to data output. Optional.
* Omit (undefined) to use the class provided HTMLParagraphElement.
* Pass an HTMLElement to use a custom element.
* Pass null to disable automatic message output.
*/
constructor(exampleObject: TRow, displayNamesAndOrder?: Record<keyof TRow, string>, messageElement?: HTMLElement | null | undefined) {
constructor(exampleObject: TRow, displayNamesAndOrder?: Record<keyof TRow, string>, messageElement?: HTMLElement | undefined | null) {
this.table = document.createElement("table")
this.tableBody = document.createElement("tbody");
@@ -38,15 +38,16 @@ export abstract class Table<TRow extends Object> {
this.table.appendChild(this.tableBody);
// If null it means disabled
this.messageEl = messageElement === undefined ? document.createElement("p") : messageElement;
}
/**
* Creates the table headers from the provided example object and the headers orders and names if provided (otherwise inferred)
* Creates a list of {@link Header} objects to be used in a table for the header cell values, column types, and header/column order (if provided, otherwise inferred).
* @param exampleObject An example object of TRow, e.g. User = { id: 0, name: "Name"}. Used to store the types for each column.
* @param displayNamesAndOrder The order and names of the columns on the table.
* e.g. User = { fullname: "Full Name", id: "User ID" }, the headers would be "Full Name" and "User ID" in column order and headers,
* @return A array of {@link Header<TRow>} type shape that holds the header/column info.
* @return An array of {@link Header} type shape that holds the header/column info.
*/
createHeadersFromType(
exampleObject: TRow, // Needed for runtime, since types don't exist in JS.