Fix the crash in declaration file emit when alias is used before its declaration

Fixes #938
Added another test case (#948)
Merge pull request #940 from Microsoft/asynchrounousAliasWriteCrash

Fix the crash in declaration file emit when alias is used before its declaration