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
3 changes: 1 addition & 2 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4083,10 +4083,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
}
const getCommonSourceDirectory = memoize(() => getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()));
commandLine.fileNames.forEach(fileName => {
if (isDeclarationFileName(fileName)) return;
const path = toPath(fileName);
let outputDts;
if (!fileExtensionIs(fileName, Extension.Json)) {
if (!isDeclarationFileName(fileName) && !fileExtensionIs(fileName, Extension.Json)) {
if (!commandLine.options.outFile) {
outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory);
mapOutputFileToResolvedRef!.set(toPath(outputDts), { resolvedRef, source: fileName });
Expand Down
62 changes: 62 additions & 0 deletions src/testRunner/unittests/tsbuild/moduleResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,68 @@ describe("unittests:: tsbuild:: moduleResolution:: handles the modules and optio
}),
commandLineArgs: ["-b", "packages/pkg1.tsconfig.json", "packages/pkg2.tsconfig.json", "--verbose", "--traceResolution"],
});

verifyTsc({
scenario: "moduleResolution",
subScenario: "resolution from d.ts of referenced project",
sys: () =>
TestServerHost.createWatchedSystem({
"/home/src/workspaces/project/common.d.ts": "export type OnValue = (value: number) => void",
"/home/src/workspaces/project/producer/index.ts": dedent`
export { ValueProducerDeclaration } from "./in-js"
import { OnValue } from "@common"
export interface ValueProducerFromTs {
onValue: OnValue;
}
`,
"/home/src/workspaces/project/producer/in-js.d.ts": dedent`
import { OnValue } from "@common"
export interface ValueProducerDeclaration {
onValue: OnValue;
}
`,
"/home/src/workspaces/project/producer/tsconfig.json": jsonToReadableText({
compilerOptions: {
strict: true,
composite: true,
module: "nodenext",
moduleResolution: "nodenext",
paths: {
"@common": ["../common.d.ts"],
},
libReplacement: false,
},
}),
"/home/src/workspaces/project/consumer/index.ts": dedent`
import { ValueProducerDeclaration, ValueProducerFromTs } from "@producer"
declare let v: ValueProducerDeclaration;
// n is implicitly any because onValue is actually any (despite what the tooltip says)
v.onValue = (n) => {

}

// n is implicitly number as expected
declare let v2: ValueProducerFromTs;
v2.onValue = (n) => {

}`,
"/home/src/workspaces/project/consumer/tsconfig.json": jsonToReadableText({
compilerOptions: {
strict: true,
module: "nodenext",
moduleResolution: "nodenext",
paths: {
"@producer": ["../producer/index"],
},
libReplacement: false,
},
references: [
{ path: "../producer" },
],
}),
}),
commandLineArgs: ["--b", "consumer", "--traceResolution", "-v"],
});
});

describe("unittests:: tsbuild:: moduleResolution:: impliedNodeFormat differs between projects for shared file", () => {
Expand Down
Loading
Loading