title: How do you use the Typescript compiler's Typechecker to get the declared (alias) type, rather than the resolved type?
body: <p>I realize this is somewhat obscure, but maybe someone else has run into this or knows the Typescript compiler well. I am processing Typescript files using Typescript's compiler API, based on examples like this: <a href="https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API" rel="noreferrer">https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API</a></p>
  
  <p>Imagine I have a declared function like this in Typescript:</p>
  
  <pre><code>export type DateString = string;
  export function parseDate(date: DateString): Date{
      let parsedDate = Date.parse(date);
      let retVal = new Date();
      retVal.setTime(parsedDate);
      return retVal;
  }
  </code></pre>
  
  <p>In the examples linked above, you can see methods like this defined to extract information about symbols:</p>
  
  <pre><code>function serializeSymbol(symbol: ts.Symbol): DocEntry {
      return {
          name: symbol.getName(),
          type: checker.typeToString(checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration))
      };
  }
  </code></pre>
  
  <p>When you run <code>checker.typeToString(checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration)</code> on the <code>date: DateString</code> symbol, instead of returning <code>DateString</code>, it returns <code>string</code>.  In other words, you don't get the declared type alias, but the fully resolved type. In my case, I'd like to know that the type of the <code>date</code> field is <code>DateString</code>. Is there an easy way to look up a parameter's declared type rather than its resolved type?</p>