Skip to content

evolvingVariableTypes

Reports variables declared without type annotation or initializer.

✅ This rule is included in the ts stylisticStrict presets.

Variables declared with let or var without a type annotation or initial value have an implicit any type that “evolves” based on subsequent assignments. This allows any type of value to be assigned to the variable, which can make it harder to catch type-related bugs at compile time.

TypeScript’s --noImplicitAny compiler option does not catch this case.

let value;
value = getValue();
var count;
count = 0;

This rule is not configurable.

If you are prototyping code quickly and want to defer type decisions, you may want to disable this rule temporarily. Alternately, some projects prefer to allow evolving variables, as TypeScript will still enforce safe usage of them after assignment.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.