Add handy function to lookup type from a type node.
Assign type to var decls.
Use var decl type to simplify type checks.