A let, const or class is used before its declaration runs, which throws
What it finds
console.log(total); const total = 1;: a let, const or class cannot be used before its declaration has run. In that stretch, the temporal dead zone, any use throws a ReferenceError, typeof included.
A use is reported when it comes before the end of the declaration in the text and runs as part of the same function; uses inside functions defined earlier, which may run later, are left alone, and so are uses in class field initializers, which run when an instance is created, and uses of a name bound earlier in the same declaration, as const { width, height = width } = size. Names in type positions, as implements and interfaces, in declare declarations and in .d.ts files, where nothing runs, are left alone too. Files with a with statement or syntax errors are skipped.
From the rule's source, use_before_declaration.rs.
export function setup() { console.log(total);tx0 reports: total is used before its declaration runs const total = 1; const read = () => later; const later = 2; return read() + total;} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:use-before-declaration" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:use-before-declaration] reason="..."tx0 explain tx0/ts:use-before-declaration shows the same in the terminal. Found a false positive? Report it.