Rule: strict-string-expressions

Disable implicit toString() calls

Require explicit toString() call for variables used in strings. By default only strings are allowed.

The following nodes are checked:

  • String literals (“foo” + bar)
  • ES6 templates (foo ${bar})
Notes:
TS Only Has Fixer Requires Type Info

Config

Following arguments may be optionally provided:

  • allow-empty-types allows null, undefined and never to be passed into strings without explicit conversion
Config examples
"strict-string-expressions": true
"strict-string-expressions": [true, {"allow-empty-types": true}]
Schema
{
  "properties": {
    "allow-empty-types": {
      "type": "boolean"
    }
  },
  "type": "object"
}