An object whose declared type has no toString is turned into a string

tx0/ts:object-stringified-without-to-stringrecommendedwarningreliability/strings-and-regexdepth projectbug

What it finds

` user: ${user} or "user " + user with a user declared as an interface or class that does not define toString produces user: [object Object]. Usually a property was meant, or the object should be formatted with JSON.stringify`.

The declared type is resolved across modules; reported when every part of it is an interface or class of the project and neither it nor a type it extends declares toString.

From the rule's source, object_stringified.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:object-stringified-without-to-string" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:object-stringified-without-to-string] reason="..."

tx0 explain tx0/ts:object-stringified-without-to-string shows the same in the terminal. Found a false positive? Report it.