Skip to content

Arithmetic & strings ​

Arithmetic operators work on numbers, with the usual precedence (use parentheses to group). + also concatenates strings — but never mixes the two: string + number is a compile error (TF2004), not silent coercion.

OperatorEffect
+add numbers, or concatenate strings
-subtract numbers
*multiply numbers
/divide numbers
%remainder of division

+ : add numbers, or concatenate strings ​

Between two numbers, adds. Between two strings, concatenates. Mixing a string and a number is TF2004 — convert explicitly with string(...) first.

typeflow
total: item.price + item.tax
fullName: user.firstName + " " + user.lastName

- : subtract numbers ​

typeflow
remaining: order.total - order.paid

* : multiply numbers ​

typeflow
subtotal: item.price * item.quantity

/ : divide numbers ​

typeflow
unitPrice: item.subtotal / item.quantity

% : remainder of division ​

typeflow
isEvenQty: item.quantity % 2 == 0

Playground ​

Mapping✔Playground ↗
Input JSON
Output
{
  "subtotal": 59.699999999999996,
  "tax": 11.94,
  "total": 71.63999999999999,
  "isEvenQty": false
}
inferred type{ subtotal: number; tax: number; total: number; isEvenQty: boolean; }

This example is intentionally broken — + never coerces:

typeflow
input order: { id: number }

map {
  label: "Order #" + order.id,
}

Mixed-type formatting goes through an explicit conversion — "Order #" + string(order.id) — or stays in your host language.

Next: Comparisons.

Released under the MIT License.