{"record":{"id":"d8858fe9cf6ddf77","repo":"oxc-project/oxc","slug":"missing-type-parameters-on-mock-function-call","errorCode":null,"errorMessage":"Missing type parameters on mock function call","messagePattern":"Missing type parameters on mock function call","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vitest/require_mock_type_parameters.rs","lineNumber":23,"sourceCode":"    AstKind,\n    ast::{CallExpression, ChainElement, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse oxc_str::CompactStr;\n\nuse crate::{\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    rules::PossibleJestNode,\n    utils::{\n        JestFnKind, JestGeneralFnKind, KnownMemberExpressionProperty, parse_general_jest_fn_call,\n    },\n};\n\nfn require_mock_type_parameters_diagnostic(span: Span, method_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing type parameters on mock function call\")\n        .with_help(format!(\n            \"Add a type parameter to the mock function, e.g. `vi.{method_name}<() => void>()`.\"\n        ))\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Deserialize, Clone)]\npub struct RequireMockTypeParameters(Box<RequireMockTypeParametersConfig>);\n\n#[derive(Debug, Default, Deserialize, Clone, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct RequireMockTypeParametersConfig {\n    /// Also require type parameters for `importActual` and `importMock`.\n    check_import_functions: bool,\n}\n\nimpl std::ops::Deref for RequireMockTypeParameters {\n    type Target = RequireMockTypeParametersConfig;","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vitest/require_mock_type_parameters.rs#L5-L41","documentation":"Emitted by the vitest/require-mock-type-parameters rule at a mock function creation or call (`vi.fn()`, mocked methods, etc.) that omits its generic type parameters. Without type parameters the mock's signature is untyped, losing type safety and editor support; the rule requires the expected types to be spelled out.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vitest/require_mock_type_parameters.rs:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add type parameters to the mock call, e.g. `vi.fn<(a: string) => number>()`","Type the mock against the real function type it stands in for"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}