(u: unknown, whitespace?: number | string | undefined): stringConverts an unknown value to a string for diagnostics.
When to use
Use to produce a diagnostic string from a value whose runtime type is unknown.
Details
Strings are returned unchanged. Objects are formatted as JSON using the
provided whitespace setting when possible, and values that cannot be
formatted are converted with String.
export const const toStringUnknown: (
u: unknown,
whitespace?: number | string | undefined
) => string
Converts an unknown value to a string for diagnostics.
When to use
Use to produce a diagnostic string from a value whose runtime type is unknown.
Details
Strings are returned unchanged. Objects are formatted as JSON using the
provided whitespace setting when possible, and values that cannot be
formatted are converted with String.
toStringUnknown = (u: unknownu: unknown, whitespace: string | number | undefinedwhitespace: number | string | undefined = 2): string => {
if (typeof u: unknownu === "string") {
return u: stringu
}
try {
return typeof u: unknownu === "object" ? import formatJsonformatJson(u: object | nullu, { space: string | numberspace: whitespace: string | numberwhitespace }) : var String: StringConstructor
;(value?: any) => string
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
String(u: {} | undefinedu)
} catch {
return var String: StringConstructor
;(value?: any) => string
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
String(u: unknownu)
}
}