title: Typescript error TS2322: Union type in function return values
body: <p>I've written that code, thinking that <em>Union types</em> were possible this way:</p>
  
  <pre><code>    public static template(templateName, data): [string, boolean]{
          var templateFullPath = Template.basePath + Template.templatesFolder + '/' + templateName + Template.templatesAfter + Template.ext;
          if(Template.exists(templateFullPath)){
              try{
                  return (Template._load(templateFullPath))(data);
              }catch(e){
                  console.error('Template ' + templateFullPath + ' could not be loaded.');
                  console.error(e);
              }
          }else{
              console.error('Template ' + templateFullPath + ' could not be found.');
          }
  
          return false;
      }
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <blockquote>
    <p>Using tsc v1.4.1</p>
    
    <p>error TS2322: Type 'boolean' is not assignable to type '[string, boolean]'.
      Property '0' is missing in type 'Boolean'.</p>
  </blockquote>
  
  <p>So I guess it is not possible to have a function returning either a boolean or a string, do I must use <code>any</code>?</p>
  
  <p>Doc TS: <a href="http://blogs.msdn.com/b/typescript/archive/2014/11/18/what-s-new-in-the-typescript-type-system.aspx" rel="nofollow">http://blogs.msdn.com/b/typescript/archive/2014/11/18/what-s-new-in-the-typescript-type-system.aspx</a></p>
  
  <p><em>In the meantime, I will use <code>any</code></em></p>