mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Handle already released source files that dont match scriptKind (#54401)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import * as ts from "../../_namespaces/ts";
|
||||
import {
|
||||
baselineTsserverLogs,
|
||||
closeFilesForSession,
|
||||
createLoggerWithInMemoryLogs,
|
||||
createProjectService,
|
||||
createSession,
|
||||
openFilesForSession,
|
||||
TestProjectService,
|
||||
} from "../helpers/tsserver";
|
||||
import {
|
||||
@@ -103,3 +106,39 @@ describe("unittests:: tsserver:: documentRegistry:: document registry in project
|
||||
baselineTsserverLogs("documentRegistry", "Caches the source file if script info is orphan, and orphan script info changes", service);
|
||||
});
|
||||
});
|
||||
|
||||
describe("unittests:: tsserver:: documentRegistry:: works when reusing orphan script info with different scriptKind", () => {
|
||||
it("works when reusing orphan script info with different scriptKind", () => {
|
||||
const host = createServerHost({});
|
||||
const session = createSession(host, { useInferredProjectPerProjectRoot: true, logger: createLoggerWithInMemoryLogs(host) });
|
||||
const newText = "exrpot const x = 10;";
|
||||
const content = `import x from 'react';\n${newText}`;
|
||||
openFilesForSession([
|
||||
{ file: "^/inmemory/model/6", content, scriptKindName: "TSX", projectRootPath: "/users/user/projects/san" },
|
||||
{ file: "^/inmemory/model/4", content, scriptKindName: "TSX", projectRootPath: "/users/user/projects/san" },
|
||||
], session);
|
||||
closeFilesForSession(["^/inmemory/model/4"], session);
|
||||
session.executeCommandSeq<ts.server.protocol.UpdateOpenRequest>({
|
||||
command: ts.server.protocol.CommandTypes.UpdateOpen,
|
||||
arguments: {
|
||||
changedFiles: [{
|
||||
fileName: "^/inmemory/model/6",
|
||||
textChanges: [{
|
||||
newText,
|
||||
start: { line: 1, offset: 1 },
|
||||
end: { line: 2, offset: newText.length + 1 } // Remove the import so that structure is not reused
|
||||
}]
|
||||
}],
|
||||
openFiles: [
|
||||
{
|
||||
file: "^/inmemory/model/4",
|
||||
fileContent: newText,
|
||||
projectRootPath: "/users/user/projects/san", // Add same document with different script kind
|
||||
scriptKindName: "TS"
|
||||
},
|
||||
]
|
||||
}
|
||||
});
|
||||
baselineTsserverLogs("documentRegistry", "works when reusing orphan script info with different scriptKind", session);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user