Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 538 Bytes

no-as-any.md

File metadata and controls

25 lines (17 loc) · 538 Bytes

Disallow any type assertions (no-as-any)

After all, remember that all the convenience of any comes at the cost of losing type safety.

Asserting the type as any avoids most type problems, but this usually leads to type insecurity. In most cases, using a non-empty assertion, asserting it as a definite type, or using as never will solve the problem.

Fail

let value = foo() as any

Pass

let value = foo() as unknown
let value = foo() as any[]
let value = foo() as Foo<any>