1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-01 05:21:43 +02:00

Remove duplication (#5311)

This commit is contained in:
boc-the-git
2024-03-11 16:14:52 +11:00
committed by GitHub
parent cd6232035f
commit da526fa684

View File

@@ -11,8 +11,8 @@ let strLength: number = (someValue as string).length;
console.log(strLength); // Outputs: 18 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 runtime type of a value, and do not cause any type of conversion. They simply provide a way for the programmer to override the type inference performed by the compiler. It's important to note that type assertions do not change the runtime type of a value, and do not cause any type of conversion. They are a compile-time construct used for static type checking in TypeScript.
- [Type assertions](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions) - [Type assertions](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions)