Fixing `noImplicitAny` Errors

This lesson discusses techniques of addressing compilation errors caused by enabling `noImplicitAny`.

Explicit any annotation

The simplest way to fix errors caused by enabling noImplicitAny is simply explicitly marking the type as any. How is this better than skipping the type annotation altogether? It’s still unsafe, right?

Correct; but with explicit annotations, it’s much easier to spot these occurrences (for example, during code reviews). Because of the propagating aspect of any, it’s easy to not realize that some portion of code is not type-checked. Making any explicit addresses this issue.

Get hands-on with 1400+ tech skills courses.