TypeInference: properly set type of declarations