Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,22 @@ namespace ts {
removeSemanticDiagnosticsOf(state, f.resolvedPath)
);
}
// When file is added to affected file because of global file change, the signature will not be update
Comment thread
amcasey marked this conversation as resolved.
Outdated
// we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file
BuilderState.updateShapeSignature(
state,
Debug.checkDefined(state.program),
affectedFile,
Debug.checkDefined(state.currentAffectedFilesSignatures),
cancellationToken,
computeHash,
state.currentAffectedFilesExportedModulesMap
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once merged with #42960 this has to be added here:

/*avoidInitializingSignatures*/ true

return;
}
else {
Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || state.currentAffectedFilesSignatures?.has(affectedFile.resolvedPath), `Signature not updated for affeted file: ${affectedFile.fileName}`);
Comment thread
sheetalkamat marked this conversation as resolved.
Outdated
Comment thread
sheetalkamat marked this conversation as resolved.
Outdated
}

if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, (state, path) => handleDtsMayChangeOf(state, path, cancellationToken, computeHash));
Expand Down
52 changes: 52 additions & 0 deletions src/testRunner/unittests/tsc/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,58 @@ const a: string = 10;`, "utf-8"),
}
});

verifyTscSerializedIncrementalEdits({
scenario: "incremental",
subScenario: `when global file is added, the signatures are updated`,
fs: () => loadProjectFromFiles({
"/src/project/src/main.ts": Utils.dedent`
/// <reference path="./filePresent.ts"/>
/// <reference path="./fileNotFound.ts"/>
function main() { }
`,
"/src/project/src/anotherFileWithSameReferenes.ts": Utils.dedent`
/// <reference path="./filePresent.ts"/>
/// <reference path="./fileNotFound.ts"/>
function anotherFileWithSameReferenes() { }
`,
"/src/project/src/filePresent.ts": `function something() { return 10; }`,
"/src/project/tsconfig.json": JSON.stringify({
compilerOptions: { composite: true, },
include: ["src/**/*.ts"]
}),
}),
commandLineArgs: ["--p", "src/project"],
incrementalScenarios: [
noChangeRun,
{
subScenario: "Modify main file",
buildKind: BuildKind.IncrementalDtsChange,
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
},
{
subScenario: "Add new file and update main file",
buildKind: BuildKind.IncrementalDtsChange,
modifyFs: fs => {
fs.writeFileSync(`/src/project/src/newFile.ts`, "function foo() { return 20; }");
prependText(fs, `/src/project/src/main.ts`, `/// <reference path="./newFile.ts"/>
`);
appendText(fs, `/src/project/src/main.ts`, `foo();`);
},
},
{
subScenario: "Write file that could not be resolved",
buildKind: BuildKind.IncrementalDtsChange,
modifyFs: fs => fs.writeFileSync(`/src/project/src/fileNotFound.ts`, "function something2() { return 20; }"),
},
{
subScenario: "Modify main file",
buildKind: BuildKind.IncrementalDtsChange,
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
},
],
baselinePrograms: true,
});

const jsxLibraryContent = `
export {};
declare global {
Expand Down
Loading