Skip to main content
Version: 0.3

The language

xisto is a strict subset of TypeScript. It reads TypeScript syntax and gives it static semantics: every value has a type the compiler knows, and that type decides the machine code. What it asks in exchange for native speed is a small set of rules. This section states them, with the reason for each.

Principles​

  • TypeScript syntax, static semantics. No new syntax. The type int is the one addition; Node strips type annotations, so on Node an int is simply a number.
  • Valid xisto is valid TypeScript. A program that compiles with xisto runs on Node with the same output. The repository's test suite checks this for every program in tests/ok/: Node is the oracle.
  • Nothing implicit. Conversions that JavaScript does silently (1 == "1", if (n) on a number) are either refused or compiled with a warning that says what happens.
  • Good errors. Every diagnostic has a stable code, the place, the rule and a fix:
x.ts:3:16: error[XS8082]: array index must be int, but this is number
3 | console.log(xs[k]);
| ^
help: declare the index as int, or convert it with Math.trunc(x)

What changes for you​

Most typed TypeScript compiles as written. The rules you meet first:

RulePage
int and number are different typesNumbers
null is the only empty value; undefined reads as nullnull and absent values
== never converts; numbers are not conditionsEquality and truthiness
any works, but takes a slower, checked pathany
generics are compiled once per typeClasses, interfaces and generics
await f() is a direct callFunctions and async

Map of this section​

For the performance side of these rules, see Best practices.