I was wondering about the type guards in TypeScript, and if it is necessary to use them when only one type is defined in method signature. All examples in TypeScript docs only refer to situations when you have union type, e.g.:
myMethod(argument: string | number) {
if (typeof argument === 'string') { // do my thing }
if (typeof argument === 'number') { // do my thing }
But I've seen people using typeof when the type is strongly typed:
myMethod(argument: string) {
if (typeof argument === 'string') { // do my thing }
Do you think it's a good approach? How do you check your data, especially the one that is not available during compile (e.g. from API endpoint)?