{"record":{"id":"5ce9413b09b91f8b","repo":"microsoft/TypeScript","slug":"did-you-mean-to-put-preferences-in-the-previous","errorCode":null,"errorMessage":"Did you mean to put 'preferences' in the previous 'verify.completions' object argument instead of their own object?","messagePattern":"Did you mean to put 'preferences' in the previous 'verify\\.completions' object argument instead of their own object\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/fourslashInterfaceImpl.ts","lineNumber":283,"sourceCode":"        source: string;\r\n        description: string;\r\n        newFileContent?: string;\r\n        newRangeContent?: string;\r\n    }) => void;\r\n}\r\n\r\nexport class Verify extends VerifyNegatable {\r\n    constructor(state: FourSlash.TestState) {\r\n        super(state);\r\n    }\r\n\r\n    public completions(...optionsArray: VerifyCompletionsOptions[]): CompletionsResult | undefined {\r\n        if (optionsArray.length === 1) {\r\n            return this.state.verifyCompletions(optionsArray[0]);\r\n        }\r\n        for (const options of optionsArray) {\r\n            if (options.preferences && Object.keys(options).length === 1 && optionsArray.length > 1 && optionsArray.indexOf(options) > 0) {\r\n                throw new Error(\"Did you mean to put 'preferences' in the previous 'verify.completions' object argument instead of their own object?\");\r\n            }\r\n            this.state.verifyCompletions(options);\r\n        }\r\n        return {\r\n            andApplyCodeAction: () => {\r\n                throw new Error(\"Cannot call andApplyCodeAction on multiple completions requests\");\r\n            },\r\n        };\r\n    }\r\n\r\n    public baselineInlayHints(span: ts.TextSpan, preference?: ts.UserPreferences): void {\r\n        this.state.baselineInlayHints(span, preference);\r\n    }\r\n\r\n    public quickInfoIs(expectedText: string, expectedDocumentation?: string, expectedTags?: { name: string; text: string; }[]): void {\r\n        this.state.verifyQuickInfoString(expectedText, expectedDocumentation, expectedTags);\r\n    }\r\n\r","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/fourslashInterfaceImpl.ts#L265-L301","documentation":"Thrown by Verify.completions when called with multiple option objects and one of them (at index > 0) is a standalone preferences object (only a preferences key with no other properties). The harness detects this pattern because a lone preferences object in a subsequent slot is almost always a mistake — preferences should be nested inside the preceding completions-options argument.","triggerScenarios":"Calling verify.completions({...}, { preferences: {...} }) where the second argument contains only preferences. The check requires options.preferences truthy, Object.keys(options).length === 1, optionsArray.length > 1, and optionsArray.indexOf(options) > 0.","commonSituations":"Test author splits the call into two objects intending to pass completion options and user preferences separately, rather than nesting preferences inside the first argument's preferences field.","solutions":["Move the preferences object into the previous argument's preferences property: verify.completions({ ..., preferences: {...} }).","If you genuinely need different preference sets across completions calls, split into separate verify.completions(...) invocations."],"exampleFix":"// before\nverify.completions(\n    { include: [\"x\"] },\n    { preferences: { includeInlayParameterHints: true } }\n);\n// after\nverify.completions({\n    include: [\"x\"],\n    preferences: { includeInlayParameterHints: true }\n});","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isPreferencesOnly(o: VerifyCompletionsOptions): o is { preferences: ts.UserPreferences } {\n    return !!o.preferences && Object.keys(o).length === 1;\n}\n// Usage: merge preferences into the preceding options object before calling\nfor (let i = 1; i < optionsArray.length; i++) {\n    if (isPreferencesOnly(optionsArray[i])) {\n        Object.assign(optionsArray[i - 1], optionsArray[i]);\n        optionsArray.splice(i, 1);\n    }\n}","tryCatchPattern":null,"preventionTips":["Nest preferences inside the completions-options object it modifies rather than passing it separately.","When refactoring a multi-arg verify.completions call, double-check that preferences land inside an options object."],"tags":["fourslash","completions","api-misuse","preferences"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}