Skip to content

Commit 4fdabf1

Browse files
committed
Merge branch 'master' into flattened-path-based-diagnostics
2 parents 8d3038a + ff10599 commit 4fdabf1

38 files changed

+835
-245
lines changed

.vscode/settings.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
}
77
],
88
"eslint.options": {
9-
"rulePaths": ["../scripts/eslint/built/rules/"],
9+
"rulePaths": ["./scripts/eslint/built/rules/"],
1010
"ext": [".ts"]
11-
},
12-
"eslint.workingDirectories": ["./src", "./scripts"]
11+
}
1312
}

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Design changes will not be accepted at this time. If you have a design change pr
7171

7272
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
7373

74-
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.pdf](https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf)), sign, scan, and email it back to <[email protected]>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request.
74+
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.pdf](https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf)), sign, scan, and email it back to <[email protected]>. Be sure to include your GitHub user name along with the agreement. Once we have received the signed CLA, we'll review the request.
7575

7676
## Housekeeping
7777

@@ -148,7 +148,7 @@ You will probably only want to debug one test at a time:
148148
gulp runtests-browser --tests=2dArrays
149149
```
150150

151-
You can specify which browser to use for debugging. Currently Chrome and IE are supported:
151+
You can specify which browser to use for debugging. Currently, Chrome and IE are supported:
152152

153153
```Shell
154154
gulp runtests-browser --tests=2dArrays --browser=chrome

Gulpfile.js

+2
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ task("run-eslint-rules-tests").description = "Runs the eslint rule tests";
333333

334334
const lintFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("lint")); };
335335
const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lint")); };
336+
337+
/** @type { (folder: string) => { (): Promise<any>; displayName?: string } } */
336338
const eslint = (folder) => async () => {
337339
const ESLINTRC_CI = ".eslintrc.ci.json";
338340
const isCIEnv = cmdLineOptions.ci || process.env.CI === "true";

scripts/post-vsts-artifact-comment.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ async function main() {
2828
type: "token",
2929
token: process.argv[2]
3030
});
31+
32+
// Please keep the strings "an installable tgz" and "packed" in this message, as well as the devDependencies section,
33+
// so that the playgrounds deployment process can find these comments.
34+
3135
await gh.issues.createComment({
3236
number: +process.env.SOURCE_ISSUE,
3337
owner: "Microsoft",
@@ -43,6 +47,9 @@ async function main() {
4347
and then running \`npm install\`.
4448
`
4549
});
50+
51+
// Send a ping to https://github.com/orta/make-monaco-builds#pull-request-builds
52+
await gh.request("POST /repos/orta/make-monaco-builds/dispatches", { event_type: +process.env.SOURCE_ISSUE })
4653
}
4754

4855
main().catch(async e => {
@@ -61,4 +68,4 @@ main().catch(async e => {
6168
body: `Hey @${process.env.REQUESTING_USER}, something went wrong when looking for the build artifact. ([You can check the log here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary)).`
6269
});
6370
}
64-
});
71+
});

scripts/types/ambient.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,15 @@ declare module "undertaker" {
7676
interface TaskFunctionParams {
7777
flags?: Record<string, string>;
7878
}
79+
interface TaskFunctionWrapped {
80+
description: string
81+
flags: { [name: string]: string }
82+
}
7983
}
8084

8185
declare module "gulp-sourcemaps" {
8286
interface WriteOptions {
8387
destPath?: string;
8488
}
85-
}
89+
90+
}

src/compiler/builder.ts

+31-5
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ namespace ts {
173173
const compilerOptions = newProgram.getCompilerOptions();
174174
state.compilerOptions = compilerOptions;
175175
// With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
176-
// With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors
177-
if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) {
176+
if (!compilerOptions.outFile && !compilerOptions.out) {
178177
state.semanticDiagnosticsPerFile = createMap<readonly Diagnostic[]>();
179178
}
180179
state.changedFilesSet = createMap<true>();
@@ -257,7 +256,7 @@ namespace ts {
257256

258257
function convertToDiagnostics(diagnostics: readonly ReusableDiagnostic[], newProgram: Program, getCanonicalFileName: GetCanonicalFileName): readonly Diagnostic[] {
259258
if (!diagnostics.length) return emptyArray;
260-
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getOutputPathForBuildInfo(newProgram.getCompilerOptions())!, newProgram.getCurrentDirectory()));
259+
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions())!, newProgram.getCurrentDirectory()));
261260
return diagnostics.map(diagnostic => {
262261
const result: Diagnostic = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
263262
result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -483,16 +482,43 @@ namespace ts {
483482
return !state.semanticDiagnosticsFromOldState.size;
484483
}
485484

485+
function isChangedSignagure(state: BuilderProgramState, path: Path) {
486+
const newSignature = Debug.assertDefined(state.currentAffectedFilesSignatures).get(path);
487+
const oldSignagure = Debug.assertDefined(state.fileInfos.get(path)).signature;
488+
return newSignature !== oldSignagure;
489+
}
490+
486491
/**
487492
* Iterate on referencing modules that export entities from affected file
488493
*/
489494
function forEachReferencingModulesOfExportOfAffectedFile(state: BuilderProgramState, affectedFile: SourceFile, fn: (state: BuilderProgramState, filePath: Path) => boolean) {
490495
// If there was change in signature (dts output) for the changed file,
491496
// then only we need to handle pending file emit
492-
if (!state.exportedModulesMap || state.affectedFiles!.length === 1 || !state.changedFilesSet.has(affectedFile.path)) {
497+
if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) {
493498
return;
494499
}
495500

501+
if (!isChangedSignagure(state, affectedFile.path)) return;
502+
503+
// Since isolated modules dont change js files, files affected by change in signature is itself
504+
// But we need to cleanup semantic diagnostics and queue dts emit for affected files
505+
if (state.compilerOptions.isolatedModules) {
506+
const seenFileNamesMap = createMap<true>();
507+
seenFileNamesMap.set(affectedFile.path, true);
508+
const queue = BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
509+
while (queue.length > 0) {
510+
const currentPath = queue.pop()!;
511+
if (!seenFileNamesMap.has(currentPath)) {
512+
seenFileNamesMap.set(currentPath, true);
513+
const result = fn(state, currentPath);
514+
if (result && isChangedSignagure(state, currentPath)) {
515+
const currentSourceFile = Debug.assertDefined(state.program).getSourceFileByPath(currentPath)!;
516+
queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
517+
}
518+
}
519+
}
520+
}
521+
496522
Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
497523
const seenFileAndExportsOfFile = createMap<true>();
498524
// Go through exported modules from cache first
@@ -656,7 +682,7 @@ namespace ts {
656682
function getProgramBuildInfo(state: Readonly<ReusableBuilderProgramState>, getCanonicalFileName: GetCanonicalFileName): ProgramBuildInfo | undefined {
657683
if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined;
658684
const currentDirectory = Debug.assertDefined(state.program).getCurrentDirectory();
659-
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getOutputPathForBuildInfo(state.compilerOptions)!, currentDirectory));
685+
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions)!, currentDirectory));
660686
const fileInfos: MapLike<BuilderState.FileInfo> = {};
661687
state.fileInfos.forEach((value, key) => {
662688
const signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);

src/compiler/builderState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ namespace ts.BuilderState {
466466
/**
467467
* Gets the files referenced by the the file path
468468
*/
469-
function getReferencedByPaths(state: Readonly<BuilderState>, referencedFilePath: Path) {
469+
export function getReferencedByPaths(state: Readonly<BuilderState>, referencedFilePath: Path) {
470470
return arrayFrom(mapDefinedIterator(state.referencedMap!.entries(), ([filePath, referencesInFile]) =>
471471
referencesInFile.has(referencedFilePath) ? filePath as Path : undefined
472472
));

0 commit comments

Comments
 (0)