Skip to content

Commit f5a8cef

Browse files
committed
merge from latest master
2 parents f8c304c + 0ae938b commit f5a8cef

File tree

268 files changed

+4580
-5713
lines changed

Some content is hidden

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

268 files changed

+4580
-5713
lines changed

.eslintignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,3 @@
22
/tests/**
33
/lib/**
44
/src/lib/*.generated.d.ts
5-
6-
# TODO: Remove the following once typescript-eslint supports `awaited`:
7-
/src/lib/es5.d.ts
8-
/src/lib/es2015.iterable.d.ts
9-
/src/lib/es2015.promise.d.ts
10-
/src/lib/es2018.promise.d.ts
11-
/src/lib/es2020.promise.d.ts
12-
/src/lib/esnext.promise.d.ts

src/compiler/binder.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,9 @@ namespace ts {
833833
case SyntaxKind.CallExpression:
834834
bindCallExpressionFlow(<CallExpression>node);
835835
break;
836+
case SyntaxKind.NonNullExpression:
837+
bindNonNullExpressionFlow(<NonNullExpression>node);
838+
break;
836839
case SyntaxKind.JSDocTypedefTag:
837840
case SyntaxKind.JSDocCallbackTag:
838841
case SyntaxKind.JSDocEnumTag:
@@ -1668,15 +1671,17 @@ namespace ts {
16681671
}
16691672

16701673
function bindOptionalChainRest(node: OptionalChain) {
1671-
bind(node.questionDotToken);
16721674
switch (node.kind) {
16731675
case SyntaxKind.PropertyAccessExpression:
1676+
bind(node.questionDotToken);
16741677
bind(node.name);
16751678
break;
16761679
case SyntaxKind.ElementAccessExpression:
1680+
bind(node.questionDotToken);
16771681
bind(node.argumentExpression);
16781682
break;
16791683
case SyntaxKind.CallExpression:
1684+
bind(node.questionDotToken);
16801685
bindEach(node.typeArguments);
16811686
bindEach(node.arguments);
16821687
break;
@@ -1695,7 +1700,7 @@ namespace ts {
16951700
// and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest
16961701
// of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost
16971702
// chain node. We then treat the entire node as the right side of the expression.
1698-
const preChainLabel = node.questionDotToken ? createBranchLabel() : undefined;
1703+
const preChainLabel = isOptionalChainRoot(node) ? createBranchLabel() : undefined;
16991704
bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
17001705
if (preChainLabel) {
17011706
currentFlow = finishFlowLabel(preChainLabel);
@@ -1718,7 +1723,16 @@ namespace ts {
17181723
}
17191724
}
17201725

1721-
function bindAccessExpressionFlow(node: AccessExpression) {
1726+
function bindNonNullExpressionFlow(node: NonNullExpression | NonNullChain) {
1727+
if (isOptionalChain(node)) {
1728+
bindOptionalChainFlow(node);
1729+
}
1730+
else {
1731+
bindEachChild(node);
1732+
}
1733+
}
1734+
1735+
function bindAccessExpressionFlow(node: AccessExpression | PropertyAccessChain | ElementAccessChain) {
17221736
if (isOptionalChain(node)) {
17231737
bindOptionalChainFlow(node);
17241738
}
@@ -1727,7 +1741,7 @@ namespace ts {
17271741
}
17281742
}
17291743

1730-
function bindCallExpressionFlow(node: CallExpression) {
1744+
function bindCallExpressionFlow(node: CallExpression | CallChain) {
17311745
if (isOptionalChain(node)) {
17321746
bindOptionalChainFlow(node);
17331747
}

src/compiler/builder.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ namespace ts {
245245
}
246246
});
247247

248-
if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
248+
// If the global file is removed, add all files as changed
249+
if (useOldState && forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath))) {
250+
BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
251+
.forEach(file => state.changedFilesSet.set(file.resolvedPath, true));
252+
}
253+
else if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
249254
// Add all files to affectedFilesPendingEmit since emit changed
250255
newProgram.getSourceFiles().forEach(f => addToAffectedFilesPendingEmit(state, f.resolvedPath, BuilderFileEmit.Full));
251256
Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
@@ -701,7 +706,7 @@ namespace ts {
701706
const fileInfos: MapLike<BuilderState.FileInfo> = {};
702707
state.fileInfos.forEach((value, key) => {
703708
const signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
704-
fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature };
709+
fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope };
705710
});
706711

707712
const result: ProgramBuildInfo = {
@@ -710,37 +715,39 @@ namespace ts {
710715
};
711716
if (state.referencedMap) {
712717
const referencedMap: MapLike<string[]> = {};
713-
state.referencedMap.forEach((value, key) => {
714-
referencedMap[relativeToBuildInfo(key)] = arrayFrom(value.keys(), relativeToBuildInfo);
715-
});
718+
for (const key of arrayFrom(state.referencedMap.keys()).sort(compareStringsCaseSensitive)) {
719+
referencedMap[relativeToBuildInfo(key)] = arrayFrom(state.referencedMap.get(key)!.keys(), relativeToBuildInfo).sort(compareStringsCaseSensitive);
720+
}
716721
result.referencedMap = referencedMap;
717722
}
718723

719724
if (state.exportedModulesMap) {
720725
const exportedModulesMap: MapLike<string[]> = {};
721-
state.exportedModulesMap.forEach((value, key) => {
726+
for (const key of arrayFrom(state.exportedModulesMap.keys()).sort(compareStringsCaseSensitive)) {
722727
const newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
723728
// Not in temporary cache, use existing value
724-
if (newValue === undefined) exportedModulesMap[relativeToBuildInfo(key)] = arrayFrom(value.keys(), relativeToBuildInfo);
729+
if (newValue === undefined) exportedModulesMap[relativeToBuildInfo(key)] = arrayFrom(state.exportedModulesMap.get(key)!.keys(), relativeToBuildInfo).sort(compareStringsCaseSensitive);
725730
// Value in cache and has updated value map, use that
726-
else if (newValue) exportedModulesMap[relativeToBuildInfo(key)] = arrayFrom(newValue.keys(), relativeToBuildInfo);
727-
});
731+
else if (newValue) exportedModulesMap[relativeToBuildInfo(key)] = arrayFrom(newValue.keys(), relativeToBuildInfo).sort(compareStringsCaseSensitive);
732+
}
728733
result.exportedModulesMap = exportedModulesMap;
729734
}
730735

731736
if (state.semanticDiagnosticsPerFile) {
732737
const semanticDiagnosticsPerFile: ProgramBuildInfoDiagnostic[] = [];
733-
// Currently not recording actual errors since those mean no emit for tsc --build
734-
state.semanticDiagnosticsPerFile.forEach((value, key) => semanticDiagnosticsPerFile.push(
735-
value.length ?
736-
[
737-
relativeToBuildInfo(key),
738-
state.hasReusableDiagnostic ?
739-
value as readonly ReusableDiagnostic[] :
740-
convertToReusableDiagnostics(value as readonly Diagnostic[], relativeToBuildInfo)
741-
] :
742-
relativeToBuildInfo(key)
743-
));
738+
for (const key of arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(compareStringsCaseSensitive)) {
739+
const value = state.semanticDiagnosticsPerFile.get(key)!;
740+
semanticDiagnosticsPerFile.push(
741+
value.length ?
742+
[
743+
relativeToBuildInfo(key),
744+
state.hasReusableDiagnostic ?
745+
value as readonly ReusableDiagnostic[] :
746+
convertToReusableDiagnostics(value as readonly Diagnostic[], relativeToBuildInfo)
747+
] :
748+
relativeToBuildInfo(key)
749+
);
750+
}
744751
result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
745752
}
746753

src/compiler/builderState.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace ts {
6868
export interface FileInfo {
6969
readonly version: string;
7070
signature: string | undefined;
71+
affectsGlobalScope: boolean;
7172
}
7273
/**
7374
* Referenced files with values for the keys as referenced file's path to be true
@@ -225,7 +226,7 @@ namespace ts {
225226
}
226227
}
227228
}
228-
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature });
229+
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
229230
}
230231

231232
return {
@@ -488,14 +489,14 @@ namespace ts {
488489
/**
489490
* Gets all files of the program excluding the default library file
490491
*/
491-
function getAllFilesExcludingDefaultLibraryFile(state: BuilderState, programOfThisState: Program, firstSourceFile: SourceFile): readonly SourceFile[] {
492+
export function getAllFilesExcludingDefaultLibraryFile(state: BuilderState, programOfThisState: Program, firstSourceFile: SourceFile | undefined): readonly SourceFile[] {
492493
// Use cached result
493494
if (state.allFilesExcludingDefaultLibraryFile) {
494495
return state.allFilesExcludingDefaultLibraryFile;
495496
}
496497

497498
let result: SourceFile[] | undefined;
498-
addSourceFile(firstSourceFile);
499+
if (firstSourceFile) addSourceFile(firstSourceFile);
499500
for (const sourceFile of programOfThisState.getSourceFiles()) {
500501
if (sourceFile !== firstSourceFile) {
501502
addSourceFile(sourceFile);

0 commit comments

Comments
 (0)