Any Type Usage (ARCH3196)
Esta página aún no está disponible en tu idioma.
Key typescript.quality.any-type-usage · Severity info · Category quality
The explicit any type and the non-null assertion (!) disable the TypeScript type checker, letting runtime errors slip through. Specific types, or narrowing from unknown, should be preferred.
Incorrect
Section titled “Incorrect”function getName(data: any): string { return data.user!.name;}Correct
Section titled “Correct”interface Payload { user?: { name: string } }
function getName(data: Payload): string { return data.user?.name ?? "anonymous";}Use a specific type or unknown instead of any, and narrow safely instead of using !.