I'm reviewing a TypeScript codebase that's filled with type assertions like this


I'm reviewing a TypeScript codebase that's filled with type assertions like this.

return fieldErrors as { [key: string]: { errors: string[] } }

Type assertions are NOT safe.

It's saying "Trust me TypeScript, it's fine."

Instead, validate. Consider Zod, ArkType, etc.

View original on X