Fix throw exception on emit file

Fix issue #852
check if the targetSourceFile is not declaration file?