{"record":{"id":"91d3bf70e8a74ff5","repo":"reflex-dev/reflex","slug":"all-parameters-of-fn-name-must-be-annotated-as","errorCode":null,"errorMessage":"All parameters of `{fn_name}` must be annotated as `rx.Var[...]` or `rx.RestProp`, got `{annotation}` for `{param_name}`.","messagePattern":"All parameters of `(.+?)` must be annotated as `rx\\.Var\\[\\.\\.\\.\\]` or `rx\\.RestProp`, got `(.+?)` for `(.+?)`\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/components/memo.py","lineNumber":1392,"sourceCode":"        annotation: The parameter annotation.\n        param_name: The parameter name (some kinds care, e.g. ``children``).\n        fn_name: The function name for error messages.\n\n    Returns:\n        The matched ``(kind, kind_data)``.\n\n    Raises:\n        TypeError: If no kind matches.\n    \"\"\"\n    for kind in _CLASSIFICATION_ORDER:\n        matched, kind_data = _SPECS[kind].classify(annotation, param_name)\n        if matched:\n            return kind, kind_data\n    msg = (\n        f\"All parameters of `{fn_name}` must be annotated as `rx.Var[...]` \"\n        f\"or `rx.RestProp`, got `{annotation}` for `{param_name}`.\"\n    )\n    raise TypeError(msg)\n\n\ndef _build_args_function(\n    params: tuple[MemoParam, ...], return_expr: Var\n) -> ArgsFunctionOperation:\n    \"\"\"Build the JS ``ArgsFunctionOperation`` that wraps a memo's return expression.\n\n    Args:\n        params: The memo parameters.\n        return_expr: The return expression of the memo body.\n\n    Returns:\n        The compiled function operation.\n    \"\"\"\n    rest_param = _get_rest_param(params)\n    if _get_children_param(params) is None and rest_param is None:\n        return ArgsFunctionOperation.create(\n            args_names=tuple(param.placeholder_name for param in params),","sourceCodeStart":1374,"sourceCodeEnd":1410,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/components/memo.py#L1374-L1410","documentation":"Every parameter of an `@rx.memo` function must be annotated with `rx.Var[...]` (or be an `rx.RestProp` / children parameter). `_classify_parameter` walks the classification order and, finding no match for the annotation, raises this TypeError telling you exactly which parameter and annotation failed.","triggerScenarios":"Decorating a function with `@rx.memo` where a parameter is unannotated or annotated with a plain type like `def badge(label: str): ...` or `def row(item): ...`. Raised at decoration time.","commonSituations":"Converting a regular render function to `@rx.memo` without adding annotations; annotating with Python types (`int`, `str`, a dataclass) instead of `rx.Var[int]`; IDE auto-removing 'unused' annotations; partial refactor where one param was missed.","solutions":["Annotate every parameter as `rx.Var[...]`, e.g. `label: rx.Var[str]`.","For prop spreads, annotate the parameter as `rx.RestProp`.","For children, use the supported children parameter convention instead of a custom annotation.","Run a quick `inspect.signature` check or rely on the error message, which names the offending parameter."],"exampleFix":"# before\n@rx.memo\ndef badge(label):\n    return rx.text(label)\n\n# after\n@rx.memo\ndef badge(label: rx.Var[str]):\n    return rx.text(label)","handlingStrategy":"type-guard","validationCode":"import inspect, typing\n\ndef has_var_annotations(fn) -> bool:\n    hints = typing.get_type_hints(fn)\n    return all(p.name in hints for p in inspect.signature(fn).parameters.values())","typeGuard":"import typing, reflex as rx\n\ndef is_valid_memo_annotation(annotation) -> bool:\n    # rx.Var[...] origins and rx.RestProp are accepted by _classify_parameter\n    if annotation is rx.RestProp or type(annotation) is type(rx.RestProp):\n        return True\n    origin = typing.get_origin(annotation)\n    return origin is not None and origin in (rx.Var, rx.Var.__class_getitem__.__self__ if hasattr(rx.Var, \"__class_getitem__\") else rx.Var)","tryCatchPattern":"try:\n    @rx.memo\n    def item(label: rx.Var[str]): ...\nexcept TypeError as e:\n    # message names the offending param; fix the annotation and re-apply\n    raise","preventionTips":["Annotate every parameter as rx.Var[...] or rx.RestProp immediately when writing the memo.","Run typing.get_type_hints on memo functions in a unit test to catch unannotated params.","Enable strict IDE type checking so unannotated parameters are flagged."],"tags":["reflex","memo","annotation","typing","typeerror"],"backgroundTag":"missing-type-annotation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}