{"record":{"id":"e785461b42c7a2b6","repo":"oxc-project/oxc","slug":"argument-is-explicitly-typed-as-any","errorCode":null,"errorMessage":"Argument is explicitly typed as `any`","messagePattern":"Argument is explicitly typed as `any`","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs","lineNumber":39,"sourceCode":"    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\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct ExplicitModuleBoundaryTypes(Box<ExplicitModuleBoundaryTypesConfig>);\n\nimpl Deref for ExplicitModuleBoundaryTypes {\n    type Target = ExplicitModuleBoundaryTypesConfig;\n\n    fn deref(&self) -> &Self::Target {\n        &self.0\n    }\n}\n\n#[derive(Debug, Clone, Deserialize, JsonSchema, PartialEq, Eq)]","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs#L21-L57","documentation":"Third diagnostic of typescript/explicit-module-boundary-types: a boundary parameter explicitly typed as `any` is reported unless allowArgumentsExplicitlyTypedAsAny is true (default false). The help text recommends `unknown` plus narrowing, because `any` opts out of type checking exactly where the contract matters most.","triggerScenarios":"`export function handle(event: any) { ... }` or a public method with an `any` parameter while allowArgumentsExplicitlyTypedAsAny is unset/false; the parameter's type annotation is TSAnyKeyword.","commonSituations":"Wrapping untyped third-party callbacks (DOM events, JSON payloads) at module edges; gradual TS migrations that sprinkled `any` on parameters; enabling noImplicitAny-style strictness after the fact.","solutions":["Change `any` to `unknown` and narrow inside: `if (typeof x === 'string') { ... }`","Model the real shape with an interface instead of `any`","During migration, set \"allowArgumentsExplicitlyTypedAsAny\": true and remove it once the edges are typed"],"exampleFix":"// before\nexport function printLength(value: any) {\n  console.log(value.length);\n}\n\n// after\nexport function printLength(value: unknown) {\n  if (typeof value === 'string') {\n    console.log(value.length);\n  }\n}","handlingStrategy":"type-guard","validationCode":"// Gate before merge: keep the rule strict in CI\n// .oxlintrc.json\n{\n  \"rules\": {\n    \"typescript/explicit-module-boundary-types\": \"warn\"\n  }\n}","typeGuard":"function isRecord(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null;\n}\n\n// narrow `unknown` at the boundary instead of accepting `any`\nexport function handle(payload: unknown): void {\n  if (isRecord(payload) && typeof payload.id === 'string') {\n    console.log(payload.id);\n  }\n}","tryCatchPattern":null,"preventionTips":["Default new boundary parameters to `unknown`; it forces narrowing and keeps the rule silent","Ban `any` in ESLint-style review: pair with no-explicit-any for non-boundary code","Zod/valibot-parse external input at the edge so internal signatures stay concrete"],"tags":["typescript","lint","any","type-safety","oxlint"],"backgroundTag":"explicit-any-parameter","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"}