fix --declaration typechecking (complex case)

This fixes generation of typescriptServices.d.ts,
although this is not a current requirement
( https://github.com/Microsoft/TypeScript/issues/465 ).
baseline for typechecking --declaration
Merge pull request #466 from sparecycles/fix/checker-declaration

fix --declaration typechecking (complex case)