агрумента?
                  
                  
                  
                  
                  
                  type ListA = {
                  
                  
                      a: string;
                  
                  
                  };
                  
                  
                  
                  
                  
                  type ListB = {
                  
                  
                      b: string;
                  
                  
                  }
                  
                  
                  
                  
                  
                  function getType(obj: ListA | ListB, useA: boolean) {
                  
                  
                      if (useA) {
                  
                  
                          return obj.a; // a does not exist in type ListB
                  
                  
                      }
                  
                  
                      return obj.b;  // b does not exist in type ListA
                  
                  
                  }
                  
                  
                
function getType(obj: Partial<ListA & ListB>) { return obj.a || obj.b; } может так?
Обсуждают сегодня