Skip to content

Commit 8c0b563

Browse files
committed
Add test for self-import resolution in .d.ts files (#62806)
1 parent 38d95c8 commit 8c0b563

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/testRunner/unittests/tsbuild/moduleResolution.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,45 @@ describe("unittests:: tsbuild:: moduleResolution:: resolution sharing", () => {
251251
}],
252252
});
253253
});
254+
255+
describe("unittests:: tsbuild:: moduleResolution:: self-import in .d.ts with project reference redirect", () => {
256+
verifyTsc({
257+
scenario: "moduleResolution",
258+
subScenario: "self-import in .d.ts resolves to dist",
259+
sys: () =>
260+
TestServerHost.createWatchedSystem({
261+
"/home/src/workspaces/project/packages/pkg1/package.json": jsonToReadableText({
262+
name: "pkg1",
263+
version: "1.0.0",
264+
main: "dist/index.js",
265+
types: "dist/index.d.ts",
266+
exports: {
267+
".": {
268+
types: "./dist/index.d.ts",
269+
default: "./dist/index.js"
270+
}
271+
}
272+
}),
273+
"/home/src/workspaces/project/packages/pkg1/tsconfig.json": jsonToReadableText({
274+
compilerOptions: {
275+
composite: true,
276+
outDir: "dist",
277+
rootDir: "src",
278+
module: "nodenext",
279+
moduleResolution: "nodenext"
280+
},
281+
include: ["src"]
282+
}),
283+
"/home/src/workspaces/project/packages/pkg1/src/index.ts": `export class C {}`,
284+
"/home/src/workspaces/project/packages/pkg1/src/other.d.ts": dedent`
285+
import { C } from "pkg1";
286+
export declare const c: C;
287+
`,
288+
"/home/src/workspaces/project/packages/pkg1/src/usage.ts": dedent`
289+
import { c } from "./other";
290+
export const usage = c;
291+
`
292+
}),
293+
commandLineArgs: ["-b", "packages/pkg1", "--verbose", "--traceResolution"],
294+
});
295+
});

0 commit comments

Comments
 (0)