Operators, keywords, and types

The sections below include the coding conventions with respect to operators, keywords, and types.

Keywords and Types

  • Do not keep spaces between the type and the pipe operator when it is in a union type (e.g., string|int).

Example,

  • Do not keep spaces between the type and the optional operator ?.

Example,

  • Avoid line breaks inside constrained types.

Do's

Don'ts

Operators

  • Keep only a single space before and after the = operator.

Example,

  • Do not keep spaces around the semicolon ;.
  • Do not keep spaces between the unary operator and the expression.

Example,

  • Keep a single space before and after any binary or ternary operator.

Example,

  • Keep a single space before and after a compound operator such as -= and +=.

Example,

  • When accessing a function, object, class or record from another module, do not keep spaces around :.

Example,

"Star"

"Watch"