A let initialized with a literal is annotated with the type it would get anyway

tx0/ts:let-annotation-repeats-literalstrictwarningstyle

What it finds

let count: number = 0, let title: string = "": a variable initialized with a literal gets the literal's primitive type without an annotation. The annotation repeats what the value already says.

Only let declarations whose annotation is number, string, boolean or bigint and whose value is a literal of that type are reported; for const, the annotation widens the literal type and so says something. The fix removes the annotation, which gives the variable the same type, and is safe.

From the rule's source, let_annotation_repeats_literal.rs.

Example from the rule's tests
let count: number = 0;tx0 reports: the value already gives this variable the type numberlet title: string = "";tx0 reports: the type stringconst fixed: number = 1;let mixed: string | number = 1;
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:let-annotation-repeats-literal" = "warning"

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:let-annotation-repeats-literal] reason="..."

tx0 explain tx0/ts:let-annotation-repeats-literal shows the same in the terminal. Found a false positive? Report it.