let strLength: number = (someValue as string).length;
let strLength: number = (someValue as string).length;
console.log(strLength); // Outputs: 20
console.log(strLength); // Outputs: 18
```
```
In this example, someValue is initially of type any, and we use the as operator to assert that it is of type string before accessing its length property. It's important to note that type assertions do not change the underlying runtime representation; they are a compile-time construct used for static type checking in TypeScript.
In this example, someValue is initially of type any, and we use the as operator to assert that it is of type string before accessing its length property. It's important to note that type assertions do not change the underlying runtime representation; they are a compile-time construct used for static type checking in TypeScript.