{"record":{"id":"e7f68716a711637c","repo":"oxc-project/oxc","slug":"the-function-type-accepts-any-function-like-valu","errorCode":null,"errorMessage":"The `Function` type accepts any function-like value.","messagePattern":"The `Function` type accepts any function-like value\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/no_unsafe_function_type.rs","lineNumber":13,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{IdentifierReference, TSTypeName},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::IsGlobalReference;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_unsafe_function_type_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"The `Function` type accepts any function-like value.\")\n        .with_help(\"Prefer explicitly defining any function parameters and return type.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnsafeFunctionType;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow using the unsafe built-in Function type.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// TypeScript's built-in Function type allows being called with any number of arguments and returns type any. Function also allows classes or plain objects that happen to possess all properties of the Function class. It's generally better to specify function parameters and return types with the function type syntax.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_unsafe_function_type.rs#L1-L31","documentation":"Raised by typescript/no-unsafe-function-type when the global `Function` type or the new Function() constructor is used. `Function` accepts any callable and defeats type checking of parameters and return values.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/no_unsafe_function_type.rs:13 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define an explicit function type: (arg: string) => void.","Use typed callback signatures instead of `Function`."],"exampleFix":null,"handlingStrategy":"validation","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-14T05:17:10.506Z"}