Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/testRunner/unittests/tscWatch/resolutionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
const scenario = "resolutionCache";
it("caching works", () => {
const root = {
path: "/a/d/f0.ts",
path: "/users/username/projects/project/d/f0.ts",
content: `import {x} from "f1"`
};
const imported = {
path: "/a/f1.ts",
path: "/users/username/projects/project/f1.ts",
content: `foo()`
};

Expand Down Expand Up @@ -99,12 +99,12 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution

it("loads missing files from disk", () => {
const root = {
path: `/a/foo.ts`,
path: `/users/username/projects/project/foo.ts`,
content: `import {x} from "bar"`
};

const imported = {
path: `/a/bar.d.ts`,
path: `/users/username/projects/project/bar.d.ts`,
content: `export const y = 1;`
};

Expand Down Expand Up @@ -157,12 +157,12 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution

it("should compile correctly when resolved module goes missing and then comes back (module is not part of the root)", () => {
const root = {
path: `/a/foo.ts`,
path: `/users/username/projects/project/foo.ts`,
content: `import {x} from "bar"`
};

const imported = {
path: `/a/bar.d.ts`,
path: `/users/username/projects/project/bar.d.ts`,
content: `export const y = 1;export const x = 10;`
};

Expand Down Expand Up @@ -262,18 +262,18 @@ declare module "fs" {
verifyTscWatch({
scenario,
subScenario: "works when included file with ambient module changes",
commandLineArgs: ["--w", "/a/b/foo.ts", "/a/b/bar.d.ts"],
commandLineArgs: ["--w", "/users/username/projects/project/foo.ts", "/users/username/projects/project/bar.d.ts"],
sys: () => {
const root = {
path: "/a/b/foo.ts",
path: "/users/username/projects/project/foo.ts",
content: `
import * as fs from "fs";
import * as u from "url";
`
};

const file = {
path: "/a/b/bar.d.ts",
path: "/users/username/projects/project/bar.d.ts",
content: `
declare module "url" {
export interface Url {
Expand All @@ -282,12 +282,12 @@ declare module "url" {
}
`
};
return createWatchedSystem([root, file, libFile], { currentDirectory: "/a/b" });
return createWatchedSystem([root, file, libFile], { currentDirectory: "/users/username/projects/project" });
},
edits: [
{
caption: "Add fs definition",
edit: sys => sys.appendFile("/a/b/bar.d.ts", `
edit: sys => sys.appendFile("/users/username/projects/project/bar.d.ts", `
declare module "fs" {
export interface Stats {
isFile(): boolean;
Expand Down
32 changes: 16 additions & 16 deletions src/testRunner/unittests/tsserver/resolutionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,69 +630,69 @@ export const x = 10;`
describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem with project references", () => {
it("sharing across references", () => {
const host = createServerHost({
"/src/projects/node_modules/moduleX/index.d.ts": "export const x = 10;",
"/src/projects/common/tsconfig.json": JSON.stringify({
"/users/username/projects/node_modules/moduleX/index.d.ts": "export const x = 10;",
"/users/username/projects/common/tsconfig.json": JSON.stringify({
compilerOptions: compilerOptionsToConfigJson({
composite: true,
traceResolution: true,
}),
}),
"/src/projects/common/moduleA.ts": "export const a = 10;",
"/src/projects/common/moduleB.ts": Utils.dedent`
"/users/username/projects/common/moduleA.ts": "export const a = 10;",
"/users/username/projects/common/moduleB.ts": Utils.dedent`
import { x } from "moduleX";
export const b = x;
`,
"/src/projects/app/tsconfig.json": JSON.stringify({
"/users/username/projects/app/tsconfig.json": JSON.stringify({
compilerOptions: compilerOptionsToConfigJson({
composite: true,
traceResolution: true,
}),
references: [{ path: "../common" }],
}),
"/src/projects/app/appA.ts": Utils.dedent`
"/users/username/projects/app/appA.ts": Utils.dedent`
import { x } from "moduleX";
export const y = x;
`,
"/src/projects/app/appB.ts": Utils.dedent`
"/users/username/projects/app/appB.ts": Utils.dedent`
import { x } from "../common/moduleB";
export const y = x;
`,
});
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
openFilesForSession(["/src/projects/app/appB.ts"], session);
openFilesForSession(["/users/username/projects/app/appB.ts"], session);
baselineTsserverLogs("resolutionCache", "sharing across references", session);
});

it("not sharing across references", () => {
const host = createServerHost({
"/src/projects/node_modules/moduleX/index.d.ts": "export const x = 10;",
"/src/projects/common/tsconfig.json": JSON.stringify({
"/users/username/projects/node_modules/moduleX/index.d.ts": "export const x = 10;",
"/users/username/projects/common/tsconfig.json": JSON.stringify({
compilerOptions: { composite: true, traceResolution: true },
}),
"/src/projects/common/moduleA.ts": "export const a = 10;",
"/src/projects/common/moduleB.ts": Utils.dedent`
"/users/username/projects/common/moduleA.ts": "export const a = 10;",
"/users/username/projects/common/moduleB.ts": Utils.dedent`
import { x } from "moduleX";
export const b = x;
`,
"/src/projects/app/tsconfig.json": JSON.stringify({
"/users/username/projects/app/tsconfig.json": JSON.stringify({
compilerOptions: {
composite: true,
traceResolution: true,
typeRoots: [], // Just some sample option that is different across the projects
},
references: [{ path: "../common" }],
}),
"/src/projects/app/appA.ts": Utils.dedent`
"/users/username/projects/app/appA.ts": Utils.dedent`
import { x } from "moduleX";
export const y = x;
`,
"/src/projects/app/appB.ts": Utils.dedent`
"/users/username/projects/app/appB.ts": Utils.dedent`
import { x } from "../common/moduleB";
export const y = x;
`,
});
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
openFilesForSession(["/src/projects/app/appB.ts"], session);
openFilesForSession(["/users/username/projects/app/appB.ts"], session);
baselineTsserverLogs("resolutionCache", "not sharing across references", session);
});
});
Loading