DEV Community

Discussion on: What's new in TypeScript v4.4?

Collapse
 
samuelsonvs profile image
Samuelsonvs • Edited

Example second of can be
catch(err ) {
console.error((err as Error).message);
}

Collapse
 
ankittanna profile image
Ankit Tanna

Yeah even this can be used. But to be honest, I hate type castings using 'as' keyword.

Collapse
 
dtiziani profile image
Tizi

if so, then it's not worth using useUnknownInCatchVariables. Using 'as' this way, you're not guarding the type, only forcing it

Collapse
 
ankittanna profile image
Ankit Tanna

yup I hate the as keyword typecasting.