Avatar ·

TypeScript or JavaScript type casting: how to properly convert data?

Hello everyone! I'm new to TypeScript and can't figure out type casting. In JavaScript, I'm used to using simple constructs like `String(value)` or `Number(value)`, as well as double negation `!!value` for boolean. But when I started writing in TypeScript, I got confused by constructs with `as` and angle brackets ``. For example, I have this code: ```typescript const data: any = fetchDataFromAPI(); // Returns any const user = data as User; // What does this mean? ``` I don't understand the difference between `as` and regular JavaScript casting. Are both methods safe? And when should I use `as`, and when is it better to use standard JavaScript functions? Also, I often see people write: ```typescript const count = someValue as number; ``` But if