Add explanation comment
This commit is contained in:
@@ -47,14 +47,15 @@ export abstract class Table<TRow extends Object> {
|
||||
exampleObject: TRow, // Needed for runtime, since types don't exist in JS.
|
||||
displayNamesAndOrder?: Record<keyof TRow, string>
|
||||
): Header<TRow>[] {
|
||||
// Checks if display names and order was passed. If not, derives the keys to use for the header from the example object.
|
||||
const keys = displayNamesAndOrder
|
||||
? (Object.keys(displayNamesAndOrder) as (keyof TRow)[])
|
||||
: (Object.keys(exampleObject) as (keyof TRow)[]);
|
||||
|
||||
return keys.map(key => ({
|
||||
key,
|
||||
value: displayNamesAndOrder?.[key] ?? String(key),
|
||||
type: typeof exampleObject[key],
|
||||
key, // Raw property name from TRow
|
||||
value: displayNamesAndOrder?.[key] ?? String(key), // The value of the th html element, with a nullish coalescing operator for if its null
|
||||
type: typeof exampleObject[key], // The type of the column
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user