{"record":{"id":"22588ca6fadb3713","repo":"microsoft/typescript-go","slug":"unexpected-number-of-arguments","errorCode":null,"errorMessage":"Unexpected number of arguments.","messagePattern":"Unexpected number of arguments\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"_extension/src/commands.ts","lineNumber":78,"sourceCode":"    else {\r\n        await jsTsConfig.update(\"experimental.useTsgo\", enable, vscode.ConfigurationTarget.Global);\r\n    }\r\n\r\n    return restartExtHostOnChangeIfNeeded();\r\n}\r\n\r\nexport async function updateWorkspaceUseTsgoSetting(enable: boolean): Promise<void> {\r\n    await vscode.workspace.getConfiguration(\"js/ts\").update(\"experimental.useTsgo\", enable, vscode.ConfigurationTarget.Workspace);\r\n    return restartExtHostOnChangeIfNeeded();\r\n}\r\n\r\nexport const codeLensShowLocationsCommandName = \"typescript.native-preview.codeLens.showLocations\";\r\nexport function registerCodeLensShowLocationsCommand(): vscode.Disposable {\r\n    return vscode.commands.registerCommand(codeLensShowLocationsCommandName, showCodeLensLocations);\r\n\r\n    function showCodeLensLocations(...args: unknown[]): void {\r\n        if (args.length !== 3) {\r\n            throw new Error(vscode.l10n.t(\"Unexpected number of arguments.\"));\r\n        }\r\n\r\n        const lspUri = args[0] as DocumentUri;\r\n        const lspPosition = args[1] as Position;\r\n        const lspLocations = args[2] as Location[];\r\n\r\n        const editorUri = vscode.Uri.parse(lspUri);\r\n        const editorPosition = new vscode.Position(lspPosition.line, lspPosition.character);\r\n        const editorLocations = lspLocations.map(loc =>\r\n            new vscode.Location(\r\n                vscode.Uri.parse(loc.uri),\r\n                new vscode.Range(\r\n                    new vscode.Position(loc.range.start.line, loc.range.start.character),\r\n                    new vscode.Position(loc.range.end.line, loc.range.end.character),\r\n                ),\r\n            )\r\n        );\r\n\r","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/_extension/src/commands.ts#L60-L96","documentation":"Thrown by the internal command typescript.native-preview.codeLens.showLocations when invoked with an argument count other than 3. The command is registered solely so the tsgo language server can trigger VS Code's reference UI from a code lens; the server invokes it with exactly (DocumentUri, Position, Location[]). Any other arity means it was invoked manually, programmatically with wrong arguments, or by a server/extension version skew.","triggerScenarios":"Executing the command by name from the command palette or executeCommand with zero arguments; a test invoking it without the (uri, position, locations) triple; an extension/server version mismatch where the server sends a different command payload shape.","commonSituations":"Users discovering the internal command in the palette and running it bare; extension developers replaying code-lens commands in tests; a stale tsgo binary from a mismatched workspace tsdk emitting arguments the newer extension does not expect.","solutions":["Do not run this internal command manually; trigger the code lens from the editor instead","If invoking programmatically, pass exactly 3 args: uri string, {line,character} position, and an array of LSP Location objects","Align extension and server versions: restart the server / reinstall so the code lens command payload matches (typescript.native-preview.restart)","If it fires from normal code-lens usage, report it - the extension and tsgo binary are out of sync"],"exampleFix":"// before\nawait vscode.commands.executeCommand(codeLensShowLocationsCommandName); // 0 args -> throws\n\n// after\nawait vscode.commands.executeCommand(\n    codeLensShowLocationsCommandName,\n    document.uri.toString(),\n    { line: 0, character: 0 },\n    [{ uri: document.uri.toString(), range: { start: { line: 0, character: 0 }, end: { line: 0, character: 5 } } }],\n);","handlingStrategy":"validation","validationCode":"// Validate the exact payload shape before executing the internal command\nfunction isCodeLensArgs(args: unknown[]): args is [string, { line: number; character: number }, Array<{ uri: string; range: unknown }>] {\n    return args.length === 3\n        && typeof args[0] === 'string'\n        && typeof (args[1] as any)?.line === 'number'\n        && Array.isArray(args[2]);\n}\nif (!isCodeLensArgs(args)) throw new Error('codeLens.showLocations expects (uri, position, locations)');\nawait vscode.commands.executeCommand(codeLensShowLocationsCommandName, ...args);","typeGuard":"const isCodeLensArgs = (a: unknown[]): a is [string, { line: number; character: number }, { uri: string; range: { start: unknown; end: unknown } }[]] =>\n    a.length === 3 && typeof a[0] === 'string' && !!a[1] && typeof (a[1] as any).line === 'number' && Array.isArray(a[2]);","tryCatchPattern":"try {\n    showCodeLensLocations(...args);\n} catch (e) {\n    if (e instanceof Error && e.message.includes('Unexpected number of arguments')) {\n        // internal command invoked with a wrong payload: log and ignore rather than surface to users\n        console.error('codeLens.showLocations invoked with', args);\n    } else throw e;\n}","preventionTips":["Never expose internal server-to-extension commands in user-facing menus","Keep extension and tsgo binary versions in lockstep (reinstall/restart on skew)","When testing commands, replicate the exact server payload arity"],"tags":["vscode","commands","code-lens","lsp","argument-validation"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}