noImplicitAnyLet
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/suspicious/noImplicitAnyLet
Since: v1.4.0
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.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.ts: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.
code-block.ts: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.