{"record":{"id":"c239521baf8fcf5a","repo":"microsoft/TypeScript","slug":"three-slash-line-in-the-middle-of-four-slash-regio","errorCode":null,"errorMessage":"Three-slash line in the middle of four-slash region at line ","messagePattern":"Three-slash line in the middle of four-slash region at line ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/fourslashImpl.ts","lineNumber":4788,"sourceCode":"\r\n        currentFileContent = undefined;\r\n        currentFileOptions = {};\r\n        currentFileName = fileName;\r\n        currentFileSymlinks = undefined;\r\n    }\r\n\r\n    for (let line of lines) {\r\n        i++;\r\n        if (line.length > 0 && line.charAt(line.length - 1) === \"\\r\") {\r\n            line = line.substr(0, line.length - 1);\r\n        }\r\n\r\n        if (line.substr(0, 4) === \"////\") {\r\n            const text = line.substr(4);\r\n            currentFileContent = currentFileContent === undefined ? text : currentFileContent + \"\\n\" + text;\r\n        }\r\n        else if (line.substr(0, 3) === \"///\" && currentFileContent !== undefined) {\r\n            throw new Error(\"Three-slash line in the middle of four-slash region at line \" + i);\r\n        }\r\n        else if (line.substr(0, 2) === \"//\") {\r\n            const possiblySymlinks = Harness.TestCaseParser.parseSymlinkFromTest(line, symlinks);\r\n            if (possiblySymlinks) {\r\n                symlinks = possiblySymlinks;\r\n            }\r\n            else {\r\n                // Comment line, check for global/file @options and record them\r\n                const match = optionRegex.exec(line.substr(2));\r\n                if (match) {\r\n                    const key = match[1].toLowerCase();\r\n                    const value = match[2];\r\n                    if (!ts.contains(fileMetadataNames, key)) {\r\n                        // Check if the match is already existed in the global options\r\n                        if (globalOptions[key] !== undefined) {\r\n                            throw new Error(`Global option '${key}' already exists`);\r\n                        }\r\n                        globalOptions[key] = value;\r","sourceCodeStart":4770,"sourceCodeEnd":4806,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/fourslashImpl.ts#L4770-L4806","documentation":"Thrown by parseTestData when a three-slash line (starting with /// but not ////) appears after fourslash content lines (starting with ////) have begun accumulating currentFileContent. The parser treats //// as file content and /// as an ambiguous instruction that must not be interleaved with four-slash blocks.","triggerScenarios":"A fourslash test file mixes //// content lines with a /// line in the same region — e.g. a stray triple-slash reference comment placed between four-slash file content lines.","commonSituations":"Test author adds a ///<reference> directive inside a four-slash block by mistake, or a copy-paste introduces a /// line where //// was intended. Also happens when trimming one slash from a //// comment accidentally.","solutions":["Inspect the line number reported in the message and convert the /// line to //// if it is meant to be file content.","If the /// line is a real triple-slash directive, move it before the first //// block (outside the four-slash region).","Remove the stray line entirely if it is not needed."],"exampleFix":"// before\n////const x = 1;\n/// <reference path=\"a.d.ts\" />\n////const y = 2;\n// after — reference moved above the four-slash region\n/// <reference path=\"a.d.ts\" />\n////const x = 1;\n////const y = 2;","handlingStrategy":"validation","validationCode":"// Pre-check that no /// lines appear after the first //// line in a test file\nconst lines = content.split(\"\\n\");\nlet sawFourSlash = false;\nfor (const line of lines) {\n    if (line.startsWith(\"////\")) sawFourSlash = true;\n    else if (sawFourSlash && line.startsWith(\"///\") && !line.startsWith(\"////\")) {\n        throw new Error(`Stray /// after //// region: ${line}`);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place all triple-slash directives above the first //// content block.","When editing fourslash files, count slashes carefully — /// vs //// have distinct meanings."],"tags":["fourslash","test-parsing","comment-syntax"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}