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.
Examples
Section titled “Examples”let value;value = getValue();var count;count = 0;let value: string;value = getValue();let value = getValue();var count = 0;var count: number;count = 0;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noImplicitAnyLet
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.