'what are the drawbacks of typecasting a variable to a dataype in TypeScript?

I have seen people take some partial object and cast with as keyword and pass it to a function that requires a certain type of object as input.

someFunctionFoo(bar: barType[]) {
//do something
}

someFunction(items.map((item: Item) => item.name) as argument[]);

What are the cons of typecasting this way?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source