{"record":{"id":"4e63ec7176b63cb9","repo":"microsoft/TypeScript","slug":"getclassifier-is-not-available-using-the-server-in","errorCode":null,"errorMessage":"getClassifier is not available using the server interface.","messagePattern":"getClassifier is not available using the server interface\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/harnessLanguageService.ts","lineNumber":807,"sourceCode":"        if (options) {\r\n            client.setCompilerOptionsForInferredProjects(ts.optionMapToObject(ts.serializeCompilerOptions(options)) as ts.server.protocol.CompilerOptions);\r\n        }\r\n\r\n        // Set the properties\r\n        this.client = client;\r\n        this.host = clientHost;\r\n    }\r\n    getLogger(): LoggerWithInMemoryLogs {\r\n        return this.logger;\r\n    }\r\n    getHost(): SessionClientHost {\r\n        return this.host;\r\n    }\r\n    getLanguageService(): ts.LanguageService {\r\n        return this.client;\r\n    }\r\n    getClassifier(): ts.Classifier {\r\n        throw new Error(\"getClassifier is not available using the server interface.\");\r\n    }\r\n    getPreProcessedFileInfo(): ts.PreProcessedFileInfo {\r\n        throw new Error(\"getPreProcessedFileInfo is not available using the server interface.\");\r\n    }\r\n    assertTextConsistent(fileName: string): void {\r\n        const serverText = this.server.getText(fileName);\r\n        const clientText = this.host.readFile(fileName);\r\n        ts.Debug.assert(\r\n            serverText === clientText,\r\n            [\r\n                \"Server and client text are inconsistent.\",\r\n                \"\",\r\n                \"\\x1b[1mServer\\x1b[0m\\x1b[31m:\",\r\n                serverText,\r\n                \"\",\r\n                \"\\x1b[1mClient\\x1b[0m\\x1b[31m:\",\r\n                clientText,\r\n                \"\",\r","sourceCodeStart":789,"sourceCodeEnd":825,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/harnessLanguageService.ts#L789-L825","documentation":"Thrown by the server-backed language service adapter (harnessLanguageService.ts:807) when a test invokes getClassifier() on a TestSession/SessionClientHost. The classifier is a compiler-internal API that the tsserver protocol does not expose, so the server adapter deliberately throws rather than pretend to support it.","triggerScenarios":"A language service test is parameterised to run both against the in-process LanguageService and against a server Session, and the test body calls `adapter.getClassifier()`. The in-process variant returns a real Classifier; the server variant throws this message.","commonSituations":"Writing a classifier/syntax-classification test and running it through the server harness; sharing one test function across both adapter kinds without gating classifier-only calls.","solutions":["Gate classifier tests to run only against the in-process adapter (skip when the adapter is the server/session variant).","Move classifier assertions into a separate test that does not exercise the server code path.","If you must assert server-side classification, use the EncodedSyntacticClassifications protocol command instead of getClassifier."],"exampleFix":"// before — runs against every adapter, throws on server variant\ntest.each(adapters)(\"classifies\", adapter => {\n  const cls = adapter.getClassifier().getClassificationsForLine(...);\n  assert.ok(cls);\n});\n\n// after — skip server variants for classifier-only tests\ntest.each(adapters.filter(a => !isServerAdapter(a)))(\"classifies\", adapter => {\n  const cls = adapter.getClassifier().getClassificationsForLine(...);\n  assert.ok(cls);\n});","handlingStrategy":"type-guard","validationCode":"// Detect server-backed adapters and skip classifier tests for them.\nfunction supportsClassifier(adapter: unknown): boolean {\n  // Server-backed adapters throw on getClassifier; detect by capability rather than type.\n  return typeof (adapter as any).getClassifier === 'function' && !isServerAdapter(adapter);\n}","typeGuard":"function isServerAdapter(adapter: unknown): boolean {\n  // SessionClientHost advertises getHost/getLanguageService but lacks a real classifier.\n  return typeof (adapter as any)?.getHost === 'function' && !(adapter as any)._classifierAvailable;\n}","tryCatchPattern":null,"preventionTips":["Gate classifier tests to run only against in-process adapters.","Use protocol commands (encodedSyntacticClassifications) for server-side classification coverage.","Document adapter capabilities in test helpers so authors know which calls are safe."],"tags":["test-harness","language-service","server-adapter","unsupported-api"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}