title: How to ensure execution order in TypeScript
body: <p>I'm trying to implement some functionalities when I end Up having an issue about execution order in typescript:</p>
  <h1>code:</h1>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>new Promise((resolve) =&gt; {
            setTimeout(()=&gt;{
              console.log("function11111");
              resolve();
            }
            ,3000);      
            
          })
          .then(_=&gt;{
            setTimeout(()=&gt;{
              console.log("function22222");
            }
            ,2000);   
          })
          .then(_=&gt;{
            setTimeout(()=&gt;{
              console.log("function3333333");
            }
            ,1000);   
          }) </code></pre>
  </div>
  </div>
  </p>
  <p>The OutPut:</p>
  <pre><code>function11111
  function33333
  function22222
  </code></pre>
  <p>My Questions are:</p>
  <p>1)for function1111, if we replace this console.log('fucntion1111') by a function that takes some seconds, in this case, my code will fire resolve() before the function finish its execution, So how to ensure the wait for my function</p>
  <p>2)In my code I'm doing then then, Why the execution doesn't respect my order ? I was thinking that promise is created for this purpose.</p>