Ensure that generated signatures are semantically correct

Part of #748 

The idea is that if we add the generated signature to the end of current project, it will not produce any type error. This PR paves the way to add syntax coloring to generated signatures.