diff --git a/vyper/context/validation/module.py b/vyper/context/validation/module.py
index <HASH>..<HASH> 100644
--- a/vyper/context/validation/module.py
+++ b/vyper/context/validation/module.py
@@ -173,6 +173,7 @@ class ModuleNodeVisitor(VyperNodeVisitorBase):
         type_definition = get_type_from_annotation(
             annotation, DataLocation.STORAGE, is_immutable, is_public
         )
+        node._metadata["type"] = type_definition
 
         if is_immutable:
             if not node.value:
@@ -198,6 +199,7 @@ class ModuleNodeVisitor(VyperNodeVisitorBase):
             raise exc.with_annotation(node) from None
         try:
             self.namespace["self"].add_member(name, type_definition)
+            node.target._metadata["type"] = type_definition
         except NamespaceCollision:
             raise NamespaceCollision(f"Value '{name}' has already been declared", node) from None
         except VyperException as exc:
@@ -214,6 +216,7 @@ class ModuleNodeVisitor(VyperNodeVisitorBase):
         func = ContractFunction.from_FunctionDef(node)
         try:
             self.namespace["self"].add_member(func.name, func)
+            node._metadata["type"] = func
         except VyperException as exc:
             raise exc.with_annotation(node) from None
feat: annotate module-level ast nodes with type data