PR comments.

This commit is contained in:
mike12345567 2023-06-14 14:34:12 +01:00
parent 68082eecf9
commit 3f63a81c01
1 changed files with 13 additions and 8 deletions

View File

@ -333,17 +333,22 @@ export function finaliseExternalTables(
* Checks if the provided input is an object, but specifically not a date type object. * Checks if the provided input is an object, but specifically not a date type object.
* Used during coercion of types and relationship handling, dates are considered valid * Used during coercion of types and relationship handling, dates are considered valid
* and can be used as a display field, but objects and arrays cannot. * and can be used as a display field, but objects and arrays cannot.
* @param test * @param testValue an unknown type which this function will attempt to extract
* a valid primary display string from.
*/ */
export function getPrimaryDisplay(test: any): string | undefined { export function getPrimaryDisplay(testValue: unknown): string | undefined {
if (test instanceof Date) { if (testValue instanceof Date) {
return test.toISOString() return testValue.toISOString()
} }
if (Array.isArray(test) && test[0] && typeof test[0] !== "object") { if (
return test.join(", ") Array.isArray(testValue) &&
testValue[0] &&
typeof testValue[0] !== "object"
) {
return testValue.join(", ")
} }
if (typeof test === "object") { if (typeof testValue === "object") {
return undefined return undefined
} }
return test as string return testValue as string
} }