Skip to content

Commit 9f844c4

Browse files
committed
Test to verify that file with --out and case mismatch works with source map
1 parent efe5dd6 commit 9f844c4

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

src/testRunner/unittests/tsserverProjectSystem.ts

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10481,20 +10481,28 @@ declare class TestLib {
1048110481
TestFSWithWatch.getTsBuildProjectFile(project, "index.ts"),
1048210482
];
1048310483
}
10484-
it("does not error on container only project", () => {
10485-
const project = "container";
10486-
const containerLib = getProjectFiles("container/lib");
10487-
const containerExec = getProjectFiles("container/exec");
10488-
const containerCompositeExec = getProjectFiles("container/compositeExec");
10489-
const containerConfig = TestFSWithWatch.getTsBuildProjectFile(project, "tsconfig.json");
10490-
const files = [libFile, ...containerLib, ...containerExec, ...containerCompositeExec, containerConfig];
10484+
10485+
const project = "container";
10486+
const containerLib = getProjectFiles("container/lib");
10487+
const containerExec = getProjectFiles("container/exec");
10488+
const containerCompositeExec = getProjectFiles("container/compositeExec");
10489+
const containerConfig = TestFSWithWatch.getTsBuildProjectFile(project, "tsconfig.json");
10490+
const files = [libFile, ...containerLib, ...containerExec, ...containerCompositeExec, containerConfig];
10491+
10492+
function createHost() {
1049110493
const host = createServerHost(files);
1049210494

1049310495
// ts build should succeed
1049410496
const solutionBuilder = tscWatch.createSolutionBuilder(host, [containerConfig.path], {});
1049510497
solutionBuilder.buildAllProjects();
1049610498
assert.equal(host.getOutput().length, 0);
1049710499

10500+
return host;
10501+
}
10502+
10503+
it("does not error on container only project", () => {
10504+
const host = createHost();
10505+
1049810506
// Open external project for the folder
1049910507
const session = createSession(host);
1050010508
const service = session.getProjectService();
@@ -10521,6 +10529,30 @@ declare class TestLib {
1052110529
assert.deepEqual(semanticDiagnostics, []);
1052210530
});
1052310531
});
10532+
10533+
it("can successfully find references with --out options", () => {
10534+
const host = createHost();
10535+
const session = createSession(host);
10536+
openFilesForSession([containerCompositeExec[1]], session);
10537+
const service = session.getProjectService();
10538+
checkNumberOfProjects(service, { configuredProjects: 1 });
10539+
const locationOfMyConst = protocolLocationFromSubstring(containerCompositeExec[1].content, "myConst");
10540+
const response = session.executeCommandSeq<protocol.RenameRequest>({
10541+
command: protocol.CommandTypes.Rename,
10542+
arguments: {
10543+
file: containerCompositeExec[1].path,
10544+
...locationOfMyConst
10545+
}
10546+
}).response as protocol.RenameResponseBody;
10547+
10548+
10549+
const myConstLen = "myConst".length;
10550+
const locationOfMyConstInLib = protocolLocationFromSubstring(containerLib[1].content, "myConst");
10551+
assert.deepEqual(response.locs, [
10552+
{ file: containerCompositeExec[1].path, locs: [{ start: locationOfMyConst, end: { line: locationOfMyConst.line, offset: locationOfMyConst.offset + myConstLen } }] },
10553+
{ file: containerLib[1].path, locs: [{ start: locationOfMyConstInLib, end: { line: locationOfMyConstInLib.line, offset: locationOfMyConstInLib.offset + myConstLen } }] }
10554+
]);
10555+
});
1052410556
});
1052510557

1052610558
describe("tsserverProjectSystem duplicate packages", () => {

tests/projects/container/compositeExec/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"compilerOptions": {
33
"outFile": "../built/local/compositeExec.js",
4-
"composite": true
4+
"composite": true,
5+
"declarationMap": true
56
},
67
"files": [
78
"index.ts"

0 commit comments

Comments
 (0)