title: Cannot get property of object (TS)
body: <p>I have ts code</p>
  
  <p>Here it is</p>
  
  <pre><code>    export function load_form_actions() {
      $('#step_2_form').on('ajax:before', function(data) {
        $('#step_2_submit_btn').hide();
        $('#step_2_form .yd-button-pop').hide();
        $('#step_2_spinner').show();
  
        if ($('input[class=error]')) {
          return Array.from($('input[class=error]')).map((input) =&gt;
            (input.className = ''));
        }
      });
  
      return $('#step_2_form').on('ajax:success', function(e, data, status, xhr) {
  
  
        if (data.errors) {
          for (let error_obj of Array.from(data.errors)) {
            if ($(`#${error_obj[0]}`).length) {
              $(`#${error_obj[0]}`).tooltipster({ contentAsHTML: true, theme: 'tooltipster-red', trigger: 'custom', content: error_obj[1].join('&lt;br /&gt;&lt;br /&gt;') });
              $(`#${error_obj[0]}`).tooltipster('open');
            }
          }
          setTimeout(() =&gt; {
                // @ts-ignore
                $.tooltipster.instances().forEach(element =&gt; {
                  element.destroy()
                });
              }, 3000);
          $('#step_2_submit_btn').show();
          $('#step_2_form .yd-button-pop').show();
          return $('#step_2_spinner').hide();
        } 
        else {
          const search_id = document.location.href.split('/')[5];
          console.dir(data);
          if ((data.result === 'ok') &amp;&amp; (data.only_save === true)) {
            let i = 0;
            let passenger = data.passengers;
            console.log(passenger);
            for (i = 0; i&lt;= passenger.length -1; i++) {
              i += 1;
              //$(`#pax_${i}_firstname`).html(passenger[i].firstname);
              //$(`#pax_${i}_lastname`).html(passenger[i].lastname);
              $(`#pax_${i}`).show();
            }
            return $.fancybox.open($('#step_2_check_names'), {
              modal : true,
              afterClose() {
                $('#step_2_submit_btn').show();
                $('#step_2_form .yd-button-pop').show();
                return $('#step_2_spinner').hide();
              }
            });
          } else if (data.result === 'ok') {
            return Helpers.navigate(data.url);
          } else if (data.result === 'step1') {
            Track.log_event("Show unable to book error screen");
            return $.fancybox.open($('#step_2_unable_to_book_error'), {
              afterClose() {
                return Helpers.navigate(data.url);
              }
            });
          } else if (data.result === 'rescheduled') {
            localStorage.setItem('rescheduled_flight', '1');
            return window.location.reload();
          } else {
            Track.log_event("Show ajax error screen");
            //Honeybadger.notify(raiseError('Ajax not OK on step_2', 'NOT OK'));
            return $.fancybox.open($('#step_2_ajax_error'), {
              afterClose() {
                return Helpers.navigate(data.url);
              }
            });
          }
        }
    });
  };
  </code></pre>
  
  <p>I need to get firstname and lastname properties of <code>data.passengers</code></p>
  
  <p>So I tried to do it like this</p>
  
  <blockquote>
    <p>//$(<code>#pax_${i}_firstname</code>).html(passenger[i].firstname);
                //$(<code>#pax_${i}_lastname</code>).html(passenger[i].lastname);</p>
  </blockquote>
  
  <p>But I get error</p>
  
  <blockquote>
    <p>Cannot get firstname of undefined.</p>
  </blockquote>
  
  <p>Here is data object</p>
  
  <p><a href="https://i.stack.imgur.com/t958k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t958k.png" alt="enter image description here"></a></p>
  
  <p>And here is <code>console.log(passenger)</code> data</p>
  
  <p><a href="https://i.stack.imgur.com/jxdkK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jxdkK.png" alt="enter image description here"></a></p>
  
  <p>I cannot understood, why I have this error?</p>
  
  <p>Thank's for help.</p>