Skip to content

Commit 54d9ce9

Browse files
committed
Merge branch 'master' into referencesPrototypeSourceFile
2 parents 6e09169 + c26c44d commit 54d9ce9

File tree

179 files changed

+5707
-1543
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+5707
-1543
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@
111111
"fs": false,
112112
"os": false,
113113
"path": false,
114-
"@microsoft/typescript-etw": false
114+
"crypto": false,
115+
"buffer": false,
116+
"@microsoft/typescript-etw": false,
117+
"source-map-support": false
115118
},
116119
"dependencies": {}
117120
}

src/compiler/binder.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,23 @@ namespace ts {
18271827
bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel,
18281828
!!findAncestor(declName, d => isPropertyAccessExpression(d) && d.name.escapedText === "prototype"), /*containerIsClass*/ false);
18291829
const oldContainer = container;
1830-
container = isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression;
1830+
switch (getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
1831+
case AssignmentDeclarationKind.ExportsProperty:
1832+
case AssignmentDeclarationKind.ModuleExports:
1833+
container = file;
1834+
break;
1835+
case AssignmentDeclarationKind.ThisProperty:
1836+
container = declName.parent.expression;
1837+
break;
1838+
case AssignmentDeclarationKind.PrototypeProperty:
1839+
container = (declName.parent.expression as PropertyAccessExpression).name;
1840+
break;
1841+
case AssignmentDeclarationKind.Property:
1842+
container = isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression;
1843+
break;
1844+
case AssignmentDeclarationKind.None:
1845+
return Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
1846+
}
18311847
declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
18321848
container = oldContainer;
18331849
}

src/compiler/builder.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ namespace ts {
137137
*/
138138
emittedBuildInfo?: boolean;
139139
/**
140-
* Already seen affected files
140+
* Already seen emitted files
141141
*/
142142
seenEmittedFiles: Map<true> | undefined;
143143
/**
@@ -329,7 +329,6 @@ namespace ts {
329329
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
330330
return affectedFile;
331331
}
332-
seenAffectedFiles.set(affectedFile.path, true);
333332
affectedFilesIndex++;
334333
}
335334

@@ -549,7 +548,7 @@ namespace ts {
549548
* This is called after completing operation on the next affected file.
550549
* The operations here are postponed to ensure that cancellation during the iteration is handled correctly
551550
*/
552-
function doneWithAffectedFile(state: BuilderProgramState, affected: SourceFile | Program, isPendingEmit?: boolean, isBuildInfoEmit?: boolean) {
551+
function doneWithAffectedFile(state: BuilderProgramState, affected: SourceFile | Program, isPendingEmit?: boolean, isBuildInfoEmit?: boolean, isEmitResult?: boolean) {
553552
if (isBuildInfoEmit) {
554553
state.emittedBuildInfo = true;
555554
}
@@ -559,6 +558,9 @@ namespace ts {
559558
}
560559
else {
561560
state.seenAffectedFiles!.set((affected as SourceFile).path, true);
561+
if (isEmitResult) {
562+
(state.seenEmittedFiles || (state.seenEmittedFiles = createMap())).set((affected as SourceFile).path, true);
563+
}
562564
if (isPendingEmit) {
563565
state.affectedFilesPendingEmitIndex!++;
564566
}
@@ -576,6 +578,14 @@ namespace ts {
576578
return { result, affected };
577579
}
578580

581+
/**
582+
* Returns the result with affected file
583+
*/
584+
function toAffectedFileEmitResult(state: BuilderProgramState, result: EmitResult, affected: SourceFile | Program, isPendingEmit?: boolean, isBuildInfoEmit?: boolean): AffectedFileResult<EmitResult> {
585+
doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, /*isEmitResult*/ true);
586+
return { result, affected };
587+
}
588+
579589
/**
580590
* Gets the semantic diagnostics either from cache if present, or otherwise from program and caches it
581591
* Note that it is assumed that the when asked about semantic diagnostics, the file has been taken out of affected files/changed file set
@@ -849,7 +859,7 @@ namespace ts {
849859
}
850860

851861
const affected = Debug.assertDefined(state.program);
852-
return toAffectedFileResult(
862+
return toAffectedFileEmitResult(
853863
state,
854864
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
855865
// Otherwise just affected file
@@ -872,14 +882,14 @@ namespace ts {
872882
}
873883
}
874884

875-
return toAffectedFileResult(
885+
return toAffectedFileEmitResult(
876886
state,
877887
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
878888
// Otherwise just affected file
879889
Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected as SourceFile, writeFile || maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers),
880890
affected,
881-
isPendingEmitFile
882-
);
891+
isPendingEmitFile,
892+
);
883893
}
884894

885895
/**
@@ -1036,7 +1046,7 @@ namespace ts {
10361046
compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath),
10371047
referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
10381048
exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
1039-
semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && arrayToMap(program.semanticDiagnosticsPerFile, value => isString(value) ? value : value[0], value => isString(value) ? emptyArray : value[1]),
1049+
semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && arrayToMap(program.semanticDiagnosticsPerFile, value => toPath(isString(value) ? value : value[0]), value => isString(value) ? emptyArray : value[1]),
10401050
hasReusableDiagnostic: true
10411051
};
10421052
return {

src/compiler/builderState.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,13 @@ namespace ts.BuilderState {
345345
}
346346
else {
347347
const emitOutput = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken);
348-
if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) {
349-
latestSignature = computeHash(emitOutput.outputFiles[0].text);
348+
const firstDts = emitOutput.outputFiles &&
349+
programOfThisState.getCompilerOptions().declarationMap ?
350+
emitOutput.outputFiles.length > 1 ? emitOutput.outputFiles[1] : undefined :
351+
emitOutput.outputFiles.length > 0 ? emitOutput.outputFiles[0] : undefined;
352+
if (firstDts) {
353+
Debug.assert(fileExtensionIs(firstDts.name, Extension.Dts), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`);
354+
latestSignature = computeHash(firstDts.text);
350355
if (exportedModulesMapCache && latestSignature !== prevSignature) {
351356
updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
352357
}

0 commit comments

Comments
 (0)