Skip to main content
Version: 0.3

Warnings

Some rules compile with a warning instead of an error: the code works, but it does something implicit or slow that you should know about. These are the rule warnings, each with a stable code.

The rule warnings​

CodeCategoryMeansFix
XS2007dynamic-pathany is used: access by name, checked at run time, about 10× slowerdeclare a type (any)
XS2101deprecatedundefined is read as nullwrite null
XS2102deprecatedcomparing a value that is never null with null: always the same resultremove the test, or declare T | null
XS2103implicitint mixed with number: the result is numberNumber(i) or Math.trunc(x)
XS2104implicita type parameter could not be inferred: it is unknownpass it: empty<Type>(...)
XS2105implicitan int as a condition, read as !== 0compare explicitly
XS2106implicit+ turns a non-string into texta template, or String(x)
XS2107implicit--tsc-checked: a value that may be null where a non-null goesif (x !== null), or x!
XS2108implicit--tsc-checked: an unknown where a type goestype it where it is made, or x as T
XS2109implicit--tsc-checked: a number where an int goes, truncateddeclare it int, or Math.trunc
XS2110implicitthe result of a generic function value is copied through JSONa concrete return type, or a generic function

Each comes with its place and a help: line:

w1.ts:4:22: warning[XS2106]: '+' turns int into text, as JavaScript does
4 | const label = "n=" + n;
| ^
help: write it as a template (`a ${x}`) or convert explicitly: String(x)

In a build​

xisto build and xisto run print one line with the count per code, not each warning:

xisto: 2 warnings (XS2106 2): --warnings lists them, xisto check --details shows where
FlagEffect
--warningslist every warning with its place
--no-warningsprint nothing about them
--deny-warningswarnings are errors (use it in CI)
--jsonone JSON object per diagnostic: severity, code, category, file, line, col, message, help, source

Warnings inside package files (.xisto/pkgs/) are not reported. Each place is reported once.

xisto check lists them apart from the changes a project needs, and --deny-warnings counts them as changes:

warnings (compile; to review) uses files
XS2101 deprecated 1 1
XS2103 implicit 1 1

Unused locals and unused functions get plain warnings without a code.

--tsc-checked​

--tsc-checked is an opt-in mode for migration, never the default. It accepts what tsc --strict already proved and xisto would refuse, and puts a run-time check where xisto cannot prove it:

CodeWithout the flagWith --tsc-checked
XS2107error: string | null where string goescompiles; TypeError: the value is null if it is
XS2108error: unknown where string goescompiles; checked at run time
XS2109error: number where int goescompiles; truncated (7 / 2 stored as 3)
XS2105error XS8022 on a number conditionread as !== 0 and not NaN

Use it to get a large codebase running, then remove the warnings one by one and drop the flag.

See also​