Skip to content

Tag: casting

Casting a number to a string in TypeScript

Which is the the best way (if there is one) to cast from number to string in Typescript? In this case the compiler throws the error: Type ‘number’ is not assignable to type ‘string’ Because location.hash is a string. So which method is better? Answer “Casting” is different …