There is a problem with type checking in TypeScript. There is an interface of the following form:
export interface ObjectRow { _id?: string; id: string; value: string | number; modificatedDate: number; } At some point, an object of type ObjectRow is received, and some actions need to be performed if a non-empty string has arrived at value. Written such a condition to check:
if (typeof object.value === 'string' && object.value.length > 0) {...} However, an error occurs in this place: "Property 'length' does not exist on type 'number'" .
In theory, the first part of the condition does not pass, the second should be ignored - but for some reason this does not happen: TypeScript considers that if there is a possibility of the number coming, then the check for length is incorrect. I have already rewrote the condition several times - TypeScript still hacks it. Can you tell where to dig? In TypeScript, I'm still a beginner, I continue to google hard. I would be grateful for any recommendations.
