Skip to content

Commit bab601b

Browse files
Merge remote-tracking branch 'origin/master' into release-4.3
2 parents 618b518 + 5b1e873 commit bab601b

File tree

1,026 files changed

+29376
-14428
lines changed

Some content is hidden

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

1,026 files changed

+29376
-14428
lines changed

.github/workflows/update-package-lock.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
# This is probably 6am UTC, which is 10pm PST or 11pm PDT
66
# Alternatively, 6am local is also fine
77
- cron: '0 6 * * *'
8+
workflow_dispatch: {}
89

910
jobs:
1011
build:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ with any additional questions or comments.
4343
## Documentation
4444

4545
* [TypeScript in 5 minutes](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html)
46-
* [Programming handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html)
46+
* [Programming handbook](https://www.typescriptlang.org/docs/handbook/intro.html)
4747
* [Homepage](https://www.typescriptlang.org/)
4848

4949
## Building

package-lock.json

+117-89
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/binder.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ namespace ts {
683683
}
684684
if (node.kind === SyntaxKind.SourceFile) {
685685
node.flags |= emitFlags;
686+
(node as SourceFile).endFlowNode = currentFlow;
686687
}
687688

688689
if (currentReturnTarget) {
@@ -2122,9 +2123,9 @@ namespace ts {
21222123
const saveParent = parent;
21232124
const saveCurrentFlow = currentFlow;
21242125
for (const typeAlias of delayedTypeAliases) {
2125-
const host = getJSDocHost(typeAlias);
2126-
container = (host && findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer))) || file;
2127-
blockScopeContainer = (host && getEnclosingBlockScopeContainer(host)) || file;
2126+
const host = typeAlias.parent.parent;
2127+
container = findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer)) || file;
2128+
blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
21282129
currentFlow = initFlowNode({ flags: FlowFlags.Start });
21292130
parent = typeAlias;
21302131
bind(typeAlias.typeExpression);
@@ -2767,8 +2768,8 @@ namespace ts {
27672768

27682769
function bindExportAssignment(node: ExportAssignment) {
27692770
if (!container.symbol || !container.symbol.exports) {
2770-
// Export assignment in some sort of block construct
2771-
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)!);
2771+
// Incorrect export assignment in some sort of block construct
2772+
bindAnonymousDeclaration(node, SymbolFlags.Value, getDeclarationName(node)!);
27722773
}
27732774
else {
27742775
const flags = exportAssignmentIsAlias(node)

src/compiler/builder.ts

+44-16
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,23 @@ namespace ts {
708708
export type ProgramBuildInfoDiagnostic = number | [fileId: number, diagnostics: readonly ReusableDiagnostic[]];
709709
export type ProgramBuilderInfoFilePendingEmit = [fileId: number, emitKind: BuilderFileEmit];
710710
export type ProgramBuildInfoReferencedMap = [fileId: number, fileIdListId: number][];
711+
export type ProgramBuildInfoBuilderStateFileInfo = Omit<BuilderState.FileInfo, "signature"> & {
712+
/**
713+
* Signature is
714+
* - undefined if FileInfo.version === FileInfo.signature
715+
* - false if FileInfo has signature as undefined (not calculated)
716+
* - string actual signature
717+
*/
718+
signature: string | false | undefined;
719+
};
720+
/**
721+
* ProgramBuildInfoFileInfo is string if FileInfo.version === FileInfo.signature && !FileInfo.affectsGlobalScope otherwise encoded FileInfo
722+
*/
723+
export type ProgramBuildInfoFileInfo = string | ProgramBuildInfoBuilderStateFileInfo;
711724
export interface ProgramBuildInfo {
712725
fileNames: readonly string[];
713-
fileInfos: readonly BuilderState.FileInfo[];
714-
options: CompilerOptions;
726+
fileInfos: readonly ProgramBuildInfoFileInfo[];
727+
options: CompilerOptions | undefined;
715728
fileIdsList?: readonly (readonly number[])[];
716729
referencedMap?: ProgramBuildInfoReferencedMap;
717730
exportedModulesMap?: ProgramBuildInfoReferencedMap;
@@ -730,12 +743,21 @@ namespace ts {
730743
const fileNameToFileId = new Map<string, number>();
731744
let fileIdsList: (readonly number[])[] | undefined;
732745
let fileNamesToFileIdListId: ESMap<string, number> | undefined;
733-
const fileInfos = arrayFrom(state.fileInfos.entries(), ([key, value]) => {
746+
const fileInfos = arrayFrom(state.fileInfos.entries(), ([key, value]): ProgramBuildInfoFileInfo => {
734747
// Ensure fileId
735748
const fileId = toFileId(key);
736749
Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
737750
const signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
738-
return signature === undefined ? value : { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope };
751+
const actualSignature = signature ?? value.signature;
752+
return value.version === actualSignature ?
753+
value.affectsGlobalScope ?
754+
{ version: value.version, signature: undefined, affectsGlobalScope: true } :
755+
value.version :
756+
actualSignature !== undefined ?
757+
signature === undefined ?
758+
value :
759+
{ version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope } :
760+
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope };
739761
});
740762

741763
let referencedMap: ProgramBuildInfoReferencedMap | undefined;
@@ -787,7 +809,7 @@ namespace ts {
787809
return {
788810
fileNames,
789811
fileInfos,
790-
options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
812+
options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
791813
fileIdsList,
792814
referencedMap,
793815
exportedModulesMap,
@@ -824,22 +846,20 @@ namespace ts {
824846
}
825847
}
826848

827-
function convertToReusableCompilerOptions(options: CompilerOptions, relativeToBuildInfo: (path: string) => string) {
828-
const result: CompilerOptions = {};
849+
function convertToProgramBuildInfoCompilerOptions(options: CompilerOptions, relativeToBuildInfo: (path: string) => string) {
850+
let result: CompilerOptions | undefined;
829851
const { optionsNameMap } = getOptionsNameMap();
830852

831-
for (const name in options) {
832-
if (hasProperty(options, name)) {
833-
result[name] = convertToReusableCompilerOptionValue(
834-
optionsNameMap.get(name.toLowerCase()),
853+
for (const name of getOwnKeys(options).sort(compareStringsCaseSensitive)) {
854+
const optionInfo = optionsNameMap.get(name.toLowerCase());
855+
if (optionInfo?.affectsEmit || optionInfo?.affectsSemanticDiagnostics || name === "skipLibCheck" || name === "skipDefaultLibCheck") {
856+
(result ||= {})[name] = convertToReusableCompilerOptionValue(
857+
optionInfo,
835858
options[name] as CompilerOptionsValue,
836859
relativeToBuildInfo
837860
);
838861
}
839862
}
840-
if (result.configFilePath) {
841-
result.configFilePath = relativeToBuildInfo(result.configFilePath);
842-
}
843863
return result;
844864
}
845865

@@ -1213,17 +1233,25 @@ namespace ts {
12131233
}
12141234
}
12151235

1236+
export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): BuilderState.FileInfo {
1237+
return isString(fileInfo) ?
1238+
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } :
1239+
isString(fileInfo.signature) ?
1240+
fileInfo as BuilderState.FileInfo :
1241+
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope };
1242+
}
1243+
12161244
export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo, buildInfoPath: string, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram {
12171245
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
12181246
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
12191247

12201248
const filePaths = program.fileNames.map(toPath);
12211249
const filePathsSetList = program.fileIdsList?.map(fileIds => new Set(fileIds.map(toFilePath)));
12221250
const fileInfos = new Map<Path, BuilderState.FileInfo>();
1223-
program.fileInfos.forEach((fileInfo, index) => fileInfos.set(toFilePath(index + 1), fileInfo));
1251+
program.fileInfos.forEach((fileInfo, index) => fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)));
12241252
const state: ReusableBuilderProgramState = {
12251253
fileInfos,
1226-
compilerOptions: convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
1254+
compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
12271255
referencedMap: toMapOfReferencedSet(program.referencedMap),
12281256
exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap),
12291257
semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && arrayToMap(program.semanticDiagnosticsPerFile, value => toFilePath(isNumber(value) ? value : value[0]), value => isNumber(value) ? emptyArray : value[1]),

src/compiler/builderState.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace ts {
7474
export interface FileInfo {
7575
readonly version: string;
7676
signature: string | undefined;
77-
affectsGlobalScope: boolean;
77+
affectsGlobalScope: boolean | undefined;
7878
}
7979
/**
8080
* Referenced files with values for the keys as referenced file's path to be true
@@ -235,7 +235,7 @@ namespace ts {
235235
}
236236
}
237237
}
238-
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
238+
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined });
239239
}
240240

241241
return {

0 commit comments

Comments
 (0)