Rule: typedef-whitespace

Requires or disallows whitespace for type definitions.

Determines if a space is required or not before the colon in a type specifier.

Notes:
TS Only Has Fixer

Config

Two arguments which are both objects. The first argument specifies how much space should be to the left of a typedef colon. The second argument specifies how much space should be to the right of a typedef colon. Each key should have a value of "onespace", "space" or "nospace". Possible keys are:

  • "call-signature" checks return type of functions.
  • "index-signature" checks index type specifier of indexers.
  • "parameter" checks function parameters.
  • "property-declaration" checks object property declarations.
  • "variable-declaration" checks variable declaration.
Config examples
"typedef-whitespace": [
  true,
  {
    "call-signature": "nospace",
    "index-signature": "nospace",
    "parameter": "nospace",
    "property-declaration": "nospace",
    "variable-declaration": "nospace"
  },
  {
    "call-signature": "onespace",
    "index-signature": "onespace",
    "parameter": "onespace",
    "property-declaration": "onespace",
    "variable-declaration": "onespace"
  }
]
Schema
{
  "type": "array",
  "items": [
    {
      "type": "object",
      "properties": {
        "call-signature": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "index-signature": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "parameter": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "property-declaration": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "variable-declaration": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "call-signature": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "index-signature": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "parameter": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "property-declaration": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        },
        "variable-declaration": {
          "type": "string",
          "enum": [
            "nospace",
            "onespace",
            "space"
          ]
        }
      },
      "additionalProperties": false
    }
  ],
  "additionalItems": false
}