// Casting = přetypování v TS nelze
// Asserce je explicitni určený typu
/*
: = type annotation (deklarace typu)
as / <> = type assertion (casting)
<T> = generic type parameter (generika)
*/
// Oba tyto řádky dělají totéž - type assertion/casting
let value: any = "hello";
let length1 = (value as string).length; // "as" syntax
let length2 = (<string>value).length; // "angle bracket" syntax
/ 1. Type annotation
let myStr: string = "hello";
// 2. Type assertion (as) - když TS neví typ
let someValue: any = "hello";
let strLength = (someValue as string).length;
// 3. Type assertion (angle brackets) - stejné jako 2
let strLength2 = (<string>someValue).length;
// 4. Generic type parameter
let myObs: Observable<number>;
let x: unknown;
x = [];
// 1
let result = (x as number[]).push(111);
// 2
let result = (<number[]>x).push(111);