|
| 1 | +import * as ts from "../../_namespaces/ts"; |
| 2 | +import { dedent } from "../../_namespaces/Utils"; |
1 | 3 | import { jsonToReadableText } from "../helpers";
|
| 4 | +import { libContent } from "../helpers/contents"; |
2 | 5 | import {
|
| 6 | + baselineTsserverLogs, |
3 | 7 | GetErrForProjectDiagnostics,
|
| 8 | + openFilesForSession, |
| 9 | + TestSession, |
4 | 10 | verifyGetErrScenario,
|
5 | 11 | } from "../helpers/tsserver";
|
6 |
| -import { File } from "../helpers/virtualFileSystemWithWatch"; |
| 12 | +import { |
| 13 | + File, |
| 14 | + libFile, |
| 15 | + TestServerHost, |
| 16 | +} from "../helpers/virtualFileSystemWithWatch"; |
7 | 17 |
|
8 |
| -describe("unittests:: tsserver:: with project references and error reporting", () => { |
| 18 | +describe("unittests:: tsserver:: projectReferenceErrors:: with project references and error reporting", () => { |
9 | 19 | const dependecyLocation = `/user/username/projects/myproject/dependency`;
|
10 | 20 | const usageLocation = `/user/username/projects/myproject/usage`;
|
11 | 21 |
|
@@ -133,4 +143,52 @@ fnErr();
|
133 | 143 | };
|
134 | 144 | verifyUsageAndDependency("with non module", dependencyTs, dependencyConfig, usageTs, usageConfig);
|
135 | 145 | });
|
| 146 | + |
| 147 | + it("when options for dependency project are different from usage project", () => { |
| 148 | + const host = new TestServerHost({ |
| 149 | + "/home/src/projects/project/a/index.ts": dedent` |
| 150 | + export function f2() { |
| 151 | + return console.log() |
| 152 | + } |
| 153 | + `, |
| 154 | + "/home/src/projects/project/a/tsconfig.json": jsonToReadableText({ |
| 155 | + compilerOptions: { |
| 156 | + composite: true, |
| 157 | + outDir: "../dist/a", |
| 158 | + }, |
| 159 | + include: ["."], |
| 160 | + }), |
| 161 | + "/home/src/projects/project/b/index.ts": dedent` |
| 162 | + import { f2 } from '../a/index.js' |
| 163 | + export function f() { |
| 164 | + f2() |
| 165 | + return console.log('') |
| 166 | + } |
| 167 | + `, |
| 168 | + "/home/src/projects/project/b/tsconfig.json": jsonToReadableText({ |
| 169 | + compilerOptions: { |
| 170 | + composite: true, |
| 171 | + isolatedDeclarations: true, |
| 172 | + outDir: "../dist/b", |
| 173 | + }, |
| 174 | + references: [{ path: "../a/" }], |
| 175 | + include: ["."], |
| 176 | + }), |
| 177 | + [libFile.path]: libContent, |
| 178 | + }); |
| 179 | + const session = new TestSession(host); |
| 180 | + openFilesForSession(["/home/src/projects/project/b/index.ts"], session); |
| 181 | + |
| 182 | + session.executeCommandSeq<ts.server.protocol.GeterrForProjectRequest>({ |
| 183 | + command: ts.server.protocol.CommandTypes.GeterrForProject, |
| 184 | + arguments: { delay: 0, file: "/home/src/projects/project/b/index.ts" }, |
| 185 | + }); |
| 186 | + host.runQueuedTimeoutCallbacks(); |
| 187 | + host.runQueuedImmediateCallbacks(); |
| 188 | + host.runQueuedImmediateCallbacks(); |
| 189 | + host.runQueuedTimeoutCallbacks(); |
| 190 | + host.runQueuedImmediateCallbacks(); |
| 191 | + host.runQueuedImmediateCallbacks(); |
| 192 | + baselineTsserverLogs("projectReferenceErrors", "when options for dependency project are different from usage project", session); |
| 193 | + }); |
136 | 194 | });
|
0 commit comments