Skip to content

Commit 5e6dcea

Browse files
committed
Merge branch 'master' into relate-empty-array-subtypes-quickly
2 parents bfcaba4 + 7e4400b commit 5e6dcea

File tree

256 files changed

+5581
-8449
lines changed

Some content is hidden

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

256 files changed

+5581
-8449
lines changed

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/binder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,9 +2123,9 @@ namespace ts {
21232123
const saveParent = parent;
21242124
const saveCurrentFlow = currentFlow;
21252125
for (const typeAlias of delayedTypeAliases) {
2126-
const host = getJSDocHost(typeAlias);
2127-
container = (host && findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer))) || file;
2128-
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;
21292129
currentFlow = initFlowNode({ flags: FlowFlags.Start });
21302130
parent = typeAlias;
21312131
bind(typeAlias.typeExpression);

src/compiler/builder.ts

Lines changed: 47 additions & 17 deletions
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,19 +846,19 @@ 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

831853
for (const name of getOwnKeys(options).sort(compareStringsCaseSensitive)) {
832-
result[name] = convertToReusableCompilerOptionValue(
833-
optionsNameMap.get(name.toLowerCase()),
834-
options[name] as CompilerOptionsValue,
835-
relativeToBuildInfo
836-
);
837-
}
838-
if (result.configFilePath) {
839-
result.configFilePath = relativeToBuildInfo(result.configFilePath);
854+
const optionInfo = optionsNameMap.get(name.toLowerCase());
855+
if (optionInfo?.affectsEmit || optionInfo?.affectsSemanticDiagnostics || name === "skipLibCheck" || name === "skipDefaultLibCheck") {
856+
(result ||= {})[name] = convertToReusableCompilerOptionValue(
857+
optionInfo,
858+
options[name] as CompilerOptionsValue,
859+
relativeToBuildInfo
860+
);
861+
}
840862
}
841863
return result;
842864
}
@@ -1211,17 +1233,25 @@ namespace ts {
12111233
}
12121234
}
12131235

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+
12141244
export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo, buildInfoPath: string, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram {
12151245
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
12161246
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
12171247

12181248
const filePaths = program.fileNames.map(toPath);
12191249
const filePathsSetList = program.fileIdsList?.map(fileIds => new Set(fileIds.map(toFilePath)));
12201250
const fileInfos = new Map<Path, BuilderState.FileInfo>();
1221-
program.fileInfos.forEach((fileInfo, index) => fileInfos.set(toFilePath(index + 1), fileInfo));
1251+
program.fileInfos.forEach((fileInfo, index) => fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)));
12221252
const state: ReusableBuilderProgramState = {
12231253
fileInfos,
1224-
compilerOptions: convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
1254+
compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
12251255
referencedMap: toMapOfReferencedSet(program.referencedMap),
12261256
exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap),
12271257
semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && arrayToMap(program.semanticDiagnosticsPerFile, value => toFilePath(isNumber(value) ? value : value[0]), value => isNumber(value) ? emptyArray : value[1]),

src/compiler/builderState.ts

Lines changed: 2 additions & 2 deletions
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)