{"record":{"id":"8ce923eebb7540e4","repo":"microsoft/TypeScript","slug":"invalid-arguments","errorCode":null,"errorMessage":"Invalid arguments","messagePattern":"Invalid arguments","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/deprecatedCompat/deprecations.ts","lineNumber":102,"sourceCode":"    if (deprecations) {\r\n        for (const key of Object.keys(deprecations)) {\r\n            const index = +key as (keyof T & number);\r\n            if (!isNaN(index) && hasProperty(overloads, `${index}`)) {\r\n                overloads[index] = deprecate(overloads[index], { ...deprecations[index], name });\r\n            }\r\n        }\r\n    }\r\n\r\n    const bind = createBinder(overloads, binder);\r\n    return call as OverloadFunction<T>;\r\n\r\n    function call(...args: OverloadParameters<T>) {\r\n        const index = bind(args);\r\n        const fn = index !== undefined ? overloads[index] : undefined;\r\n        if (typeof fn === \"function\") {\r\n            return fn(...args);\r\n        }\r\n        throw new TypeError(\"Invalid arguments\");\r\n    }\r\n}\r\n\r\nfunction createBinder<T extends OverloadDefinitions>(overloads: T, binder: OverloadBinders<T>): OverloadBinder<T> {\r\n    return args => {\r\n        for (let i = 0; hasProperty(overloads, `${i}`) && hasProperty(binder, `${i}`); i++) {\r\n            const fn = binder[i];\r\n            if (fn(args)) {\r\n                return i as OverloadKeys<T>;\r\n            }\r\n        }\r\n    };\r\n}\r\n\r\n/** @internal */\r\nexport interface OverloadBuilder {\r\n    overload<T extends OverloadDefinitions>(overloads: T): BindableOverloadBuilder<T>;\r\n}\r","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/deprecatedCompat/deprecations.ts#L84-L120","documentation":"Thrown by the `call` function produced by `createOverload` in `src/deprecatedCompat/deprecations.ts`. `createOverload` builds a runtime-overloaded function from typed overloads plus per-overload binder predicates; `call` runs the binder over the arguments, looks up the matching overload by index, and if none matches (or the matched entry isn't a function) it throws `TypeError(\"Invalid arguments\")`.","triggerScenarios":"Invoking a `deprecatedCompat` overload function (built via `createOverload`) with arguments that satisfy none of the registered binder predicates — i.e. an argument shape the overloads don't cover. Also reached if an overload entry was replaced with a non-function (e.g. a deprecation error thunk that wasn't a function).","commonSituations":"Calling an overloaded deprecated API with a wrong arg type or arity that escapes compile-time checking (via `any`); version drift where an overload was removed; calling internal `deprecatedCompat` surfaces from tooling with mismatched signatures.","solutions":["Pass arguments that match one of the documented overload signatures.","Avoid invoking through `any` — let the compiler narrow to a valid overload.","If you maintain the surface, register a binder predicate + overload that covers the arg shape.","Check the deprecation map: a removed overload may need its replacement signature."],"exampleFix":"// before\nconst fn: any = createOverload(...);\nfn({ weird: \"shape\" });   // no binder matches -> TypeError\n// after\nfn(\"expectedStringArg\"); // matches overload 0","handlingStrategy":"validation","validationCode":"// Keep the call site typed so the compiler rejects non-matching arg shapes:\nconst fn: OverloadFunction<Signatures> = createOverload(...);\nfn(\"expectedStringArg\"); // compile-time error if wrong","typeGuard":"type ArgMatches<T> = T extends (...a: infer A) => any ? A : never;","tryCatchPattern":"try { fn(input); } catch (e) { if (e instanceof TypeError && /Invalid arguments/.test(String(e))) { /* pick correct overload */ } else throw e; }","preventionTips":["Never call overloaded deprecated APIs through `any`.","Keep overload signatures and binder predicates in sync when editing `deprecatedCompat`."],"tags":["overloads","deprecation","compat","type-narrowing"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}