= (testValue: any): boolean => typeof testValue === "string";
                  
                  
                  
                  
                  
                  есть два поля
                  
                  
                  
                  
                  
                  phone: isString(phone) ? phone : '',
                  
                  
                  fullname: typeof fullname === "string" ? fullname : ''
                  
                  
                  
                  
                  
                  в первом случае ошибка:
                  
                  
                  Type 'string | string[] | null | undefined' is not assignable to type 'string'.
                  
                  
                    Type 'undefined' is not assignable to type 'string'.
                  
                  
                  
                  
                  
                  во втором все ок
                  
                  
                  
                  
                  
                  подскажите, почему так происходит?
                  
                  
                
export const isString = (testValue: any): testValue is string => typeof testValue === "string";
Обсуждают сегодня