Skip to content

noImplicitAnyLet (since v1.4.0)

Diagnostic Category: lint/suspicious/noImplicitAnyLet

Disallow use of implicit any type on variable declarations.

TypeScript variable declaration without any type annotation and initialization have the any type. The any type in TypeScript is a dangerous “escape hatch” from the type system. Using any disables many type checking rules and is generally best used only as a last resort or when prototyping code. TypeScript’s --noImplicitAny compiler option doesn’t report this case.

var a;
a = 2;
suspicious/noImplicitAnyLet.js:1:5 lint/suspicious/noImplicitAnyLet ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This variable implicitly has the any type.
  
  > 1 │ var a;
       ^
    2 │ a = 2;
    3 │ 
  
   Variable declarations without type annotation and initialization implicitly have the any type. Declare a type or initialize the variable with some value.
  
let b;
b = 1
suspicious/noImplicitAnyLet.js:1:5 lint/suspicious/noImplicitAnyLet ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This variable implicitly has the any type.
  
  > 1 │ let b;
       ^
    2 │ b = 1
    3 │ 
  
   Variable declarations without type annotation and initialization implicitly have the any type. Declare a type or initialize the variable with some value.
  
var a = 1;
let a:number;
var b: number
var b =10;