title: Typescript reflection - required parameters & default values
body: <p>In short: <strong>is there a way to know if a typescript parameter is required and/or has a default value?</strong></p>
  
  <p>Longer version:
  Say I have the following file:</p>
  
  <pre><code>//Foo.ts
  class Bar {
      foo(required:string,defaultValue:number=0,optional?:boolean) {
          ...
      }
  }
  </code></pre>
  
  <p>I would like to know of each of the parameters:</p>
  
  <ul>
  <li>the name </li>
  <li>the type </li>
  <li>is it required?</li>
  <li>does it have a default value?</li>
  </ul>
  
  <p>I have succesfully used <a href="http://blog.wolksoftware.com/decorators-metadata-reflection-in-typescript-from-novice-to-expert-part-4" rel="noreferrer">method decorators</a> with the <a href="https://github.com/rbuckton/ReflectDecorators" rel="noreferrer">TypeScript reflection API</a> to get the types of the parameters, I've used <a href="https://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically-from-javascript">this method</a> to get their names, but so far I have not found a way to know if a variable is <strong>required</strong> and/or has a <strong>default value</strong>.</p>
  
  <p>I know the typescript compiler itself can be used from within typescript. So I'm wondering if there is a way to use the parse tree of the compiler to see if a parameter is required and/or has a default value?</p>
  
  <p>How would that work?</p>