Diferencia entre usar any y unknown en typscript [ESP-ENG]

in StemSocial13 days ago

Tener estos dos tipos de valores en typescript nos permite operar de maneras diferentes a la hora de trabajar con ciertos tipos de datos.
Tal cual como lo dicen explícitamente cada uno sus funciones relativamente similar pero existe una diferencia radical a la hora de trabajarlos en el código.

Having these two types of values ​​in typescript allows us to operate in different ways when working with certain types of data. As they explicitly say, each one has relatively similar functions, but there is a radical difference when working on them in the code.
El método any lo utilizamos casi todo el tiempo y nos permite obtener resultados rápido sin necesidad de colocar el tipo de dato correcto pero hay casos en los que desconocemos qué tipo de datos pueden llegar y es mejor utilizar el otro método porque obliga al desarrollador a realizar comprobaciones de valores primitivos para descartar aquellos que no se encuentren dentro de la variable o alguna respuesta obtenida de consumo de una dirección web.
We use the any method almost all the time and it allows us to obtain results quickly without having to enter the correct type of data, but there are cases in which we do not know what type of data can be obtained and it is better to use the other method because it forces the developer to perform checks of primitive values ​​to discard those that are not found within the variable or any response obtained from consuming a web address.
Sort:  

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.