{"record":{"id":"c4c24276dda501bd","repo":"oxc-project/oxc","slug":"missing-return-type-on-function-c4c242","errorCode":null,"errorMessage":"Missing return type on function","messagePattern":"Missing return type on function","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs","lineNumber":27,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::ScopeFlags;\nuse oxc_span::GetSpan;\nuse oxc_str::CompactStr;\nuse rustc_hash::{FxHashMap, FxHashSet};\nuse schemars::JsonSchema;\nuse serde::Deserialize;\nuse serde_json::Value;\nuse smallvec::SmallVec;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn func_missing_return_type(fn_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing return type on function\")\n        .with_help(\"Define an explicit return type for the function.\")\n        .with_label(fn_span)\n}\n\nfn func_missing_argument_type(param_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing argument type on function\")\n        .with_help(\"Define an explicit argument type for each argument.\")\n        .with_label(param_span)\n}\n\nfn func_argument_is_explicitly_any(param_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Argument is explicitly typed as `any`\")\n        .with_help(\n            \"Avoid explicit `any` at module boundaries; prefer `unknown` and narrow before use.\",\n        )\n        .with_label(param_span)\n}\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs#L9-L45","documentation":"typescript/explicit-module-boundary-types requires return type annotations on exported functions and on public members of exported classes, unlike explicit-function-return-type it checks only the module's public surface. Defaults: allowTypedFunctionExpressions, allowHigherOrderFunctions, and allowDirectConstAssertionInArrowFunctions are true; allowedNames and allowOverloadFunctions (false) provide narrower exemptions.","triggerScenarios":"`export function f(x: string) { ... }` with no return annotation, or a public method on an exported class without one, where the name is not in allowedNames and no allow* exemption applies; overload signature sets are reported unless allowOverloadFunctions is enabled.","commonSituations":"Library authors wanting typed public APIs without annotating every internal function; enabling both this and explicit-function-return-type and getting duplicate pressure; overloads written for option objects being flagged.","solutions":["Annotate the exported signature: `export function parse(input: string): Result { ... }`","Add names of functions that should keep inferred returns to \"allowedNames\"","Set \"allowOverloadFunctions\": true when using overload signature groups","Prefer this rule over explicit-function-return-type when you only care about the module boundary, and disable the broader one"],"exampleFix":"// before\nexport function format(input: string) {\n  return input.trim();\n}\n\n// after\nexport function format(input: string): string {\n  return input.trim();\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — check only the exported surface\n{\n  \"rules\": {\n    \"typescript/explicit-module-boundary-types\": [\n      \"warn\",\n      { \"allowedNames\": [], \"allowOverloadFunctions\": true }\n    ]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer this rule over explicit-function-return-type for libraries; internals stay inference-friendly","Annotate exported signatures as you write them — retrofitting on a big surface is expensive","Pair with API extractor or tsc --declaration so the annotations are what consumers actually see"],"tags":["typescript","lint","annotations","return-type","api-design","oxlint"],"backgroundTag":"missing-return-type-annotation","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}