Skip to content

Commit 7b942b4

Browse files
authored
Revert the type change to ts.Map (#39366)
1 parent 852800b commit 7b942b4

Some content is hidden

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

71 files changed

+443
-405
lines changed

src/compiler/binder.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ts {
1515
referenced: boolean;
1616
}
1717

18-
export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
18+
export function getModuleInstanceState(node: ModuleDeclaration, visited?: ESMap<number, ModuleInstanceState | undefined>): ModuleInstanceState {
1919
if (node.body && !node.body.parent) {
2020
// getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already
2121
setParent(node.body, node);
@@ -35,7 +35,7 @@ namespace ts {
3535
return result;
3636
}
3737

38-
function getModuleInstanceStateWorker(node: Node, visited: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
38+
function getModuleInstanceStateWorker(node: Node, visited: ESMap<number, ModuleInstanceState | undefined>): ModuleInstanceState {
3939
// A module is uninstantiated if it contains only
4040
switch (node.kind) {
4141
// 1. interface declarations, type alias declarations
@@ -107,7 +107,7 @@ namespace ts {
107107
return ModuleInstanceState.Instantiated;
108108
}
109109

110-
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map<number, ModuleInstanceState | undefined>) {
110+
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: ESMap<number, ModuleInstanceState | undefined>) {
111111
const name = specifier.propertyName || specifier.name;
112112
let p: Node | undefined = specifier.parent;
113113
while (p) {

src/compiler/builder.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace ts {
2424
/**
2525
* Cache of bind and check diagnostics for files with their Path being the key
2626
*/
27-
semanticDiagnosticsPerFile?: ReadonlyMap<Path, readonly ReusableDiagnostic[] | readonly Diagnostic[]> | undefined;
27+
semanticDiagnosticsPerFile?: ReadonlyESMap<Path, readonly ReusableDiagnostic[] | readonly Diagnostic[]> | undefined;
2828
/**
2929
* The map has key by source file's path that has been changed
3030
*/
@@ -41,7 +41,7 @@ namespace ts {
4141
* Map of file signatures, with key being file path, calculated while getting current changed file's affected files
4242
* These will be committed whenever the iteration through affected files of current changed file is complete
4343
*/
44-
currentAffectedFilesSignatures?: ReadonlyMap<Path, string> | undefined;
44+
currentAffectedFilesSignatures?: ReadonlyESMap<Path, string> | undefined;
4545
/**
4646
* Newly computed visible to outside referencedSet
4747
*/
@@ -65,7 +65,7 @@ namespace ts {
6565
/**
6666
* Files pending to be emitted kind.
6767
*/
68-
affectedFilesPendingEmitKind?: ReadonlyMap<Path, BuilderFileEmit> | undefined;
68+
affectedFilesPendingEmitKind?: ReadonlyESMap<Path, BuilderFileEmit> | undefined;
6969
/**
7070
* Current index to retrieve pending affected file
7171
*/
@@ -89,7 +89,7 @@ namespace ts {
8989
/**
9090
* Cache of bind and check diagnostics for files with their Path being the key
9191
*/
92-
semanticDiagnosticsPerFile: Map<Path, readonly Diagnostic[]> | undefined;
92+
semanticDiagnosticsPerFile: ESMap<Path, readonly Diagnostic[]> | undefined;
9393
/**
9494
* The map has key by source file's path that has been changed
9595
*/
@@ -110,7 +110,7 @@ namespace ts {
110110
* Map of file signatures, with key being file path, calculated while getting current changed file's affected files
111111
* These will be committed whenever the iteration through affected files of current changed file is complete
112112
*/
113-
currentAffectedFilesSignatures: Map<Path, string> | undefined;
113+
currentAffectedFilesSignatures: ESMap<Path, string> | undefined;
114114
/**
115115
* Newly computed visible to outside referencedSet
116116
*/
@@ -142,7 +142,7 @@ namespace ts {
142142
/**
143143
* Files pending to be emitted kind.
144144
*/
145-
affectedFilesPendingEmitKind: Map<Path, BuilderFileEmit> | undefined;
145+
affectedFilesPendingEmitKind: ESMap<Path, BuilderFileEmit> | undefined;
146146
/**
147147
* Current index to retrieve pending affected file
148148
*/
@@ -154,7 +154,7 @@ namespace ts {
154154
/**
155155
* Already seen emitted files
156156
*/
157-
seenEmittedFiles: Map<Path, BuilderFileEmit> | undefined;
157+
seenEmittedFiles: ESMap<Path, BuilderFileEmit> | undefined;
158158
/**
159159
* true if program has been emitted
160160
*/
@@ -1140,7 +1140,7 @@ namespace ts {
11401140
}
11411141
}
11421142

1143-
function getMapOfReferencedSet(mapLike: MapLike<readonly string[]> | undefined, toPath: (path: string) => Path): ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined {
1143+
function getMapOfReferencedSet(mapLike: MapLike<readonly string[]> | undefined, toPath: (path: string) => Path): ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined {
11441144
if (!mapLike) return undefined;
11451145
const map = new Map<Path, BuilderState.ReferencedSet>();
11461146
// Copies keys/values from template. Note that for..in will not throw if

src/compiler/builderState.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@ namespace ts {
1515
/**
1616
* Information of the file eg. its version, signature etc
1717
*/
18-
fileInfos: ReadonlyMap<Path, BuilderState.FileInfo>;
18+
fileInfos: ReadonlyESMap<Path, BuilderState.FileInfo>;
1919
/**
2020
* Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled
2121
* Otherwise undefined
2222
* Thus non undefined value indicates, module emit
2323
*/
24-
readonly referencedMap?: ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined;
24+
readonly referencedMap?: ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined;
2525
/**
2626
* Contains the map of exported modules ReferencedSet=exported module files from the file if module emit is enabled
2727
* Otherwise undefined
2828
*/
29-
readonly exportedModulesMap?: ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined;
29+
readonly exportedModulesMap?: ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined;
3030
}
3131

3232
export interface BuilderState {
3333
/**
3434
* Information of the file eg. its version, signature etc
3535
*/
36-
fileInfos: Map<Path, BuilderState.FileInfo>;
36+
fileInfos: ESMap<Path, BuilderState.FileInfo>;
3737
/**
3838
* Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled
3939
* Otherwise undefined
4040
* Thus non undefined value indicates, module emit
4141
*/
42-
readonly referencedMap: ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined;
42+
readonly referencedMap: ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined;
4343
/**
4444
* Contains the map of exported modules ReferencedSet=exported module files from the file if module emit is enabled
4545
* Otherwise undefined
4646
*/
47-
readonly exportedModulesMap: Map<Path, BuilderState.ReferencedSet> | undefined;
47+
readonly exportedModulesMap: ESMap<Path, BuilderState.ReferencedSet> | undefined;
4848
/**
4949
* Map of files that have already called update signature.
5050
* That means hence forth these files are assumed to have
@@ -83,7 +83,7 @@ namespace ts {
8383
* Exported modules to from declaration emit being computed.
8484
* This can contain false in the affected file path to specify that there are no exported module(types from other modules) for this file
8585
*/
86-
export type ComputingExportedModulesMap = Map<Path, ReferencedSet | false>;
86+
export type ComputingExportedModulesMap = ESMap<Path, ReferencedSet | false>;
8787

8888
/**
8989
* Get the referencedFile from the imported module symbol
@@ -192,7 +192,7 @@ namespace ts {
192192
/**
193193
* Returns true if oldState is reusable, that is the emitKind = module/non module has not changed
194194
*/
195-
export function canReuseOldState(newReferencedMap: ReadonlyMap<Path, ReferencedSet> | undefined, oldState: Readonly<ReusableBuilderState> | undefined) {
195+
export function canReuseOldState(newReferencedMap: ReadonlyESMap<Path, ReferencedSet> | undefined, oldState: Readonly<ReusableBuilderState> | undefined) {
196196
return oldState && !oldState.referencedMap === !newReferencedMap;
197197
}
198198

@@ -258,7 +258,7 @@ namespace ts {
258258
/**
259259
* Gets the files affected by the path from the program
260260
*/
261-
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: Map<Path, string>, exportedModulesMapCache?: ComputingExportedModulesMap): readonly SourceFile[] {
261+
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: ESMap<Path, string>, exportedModulesMapCache?: ComputingExportedModulesMap): readonly SourceFile[] {
262262
// Since the operation could be cancelled, the signatures are always stored in the cache
263263
// They will be committed once it is safe to use them
264264
// eg when calling this api from tsserver, if there is no cancellation of the operation
@@ -285,7 +285,7 @@ namespace ts {
285285
* Updates the signatures from the cache into state's fileinfo signatures
286286
* This should be called whenever it is safe to commit the state of the builder
287287
*/
288-
export function updateSignaturesFromCache(state: BuilderState, signatureCache: Map<Path, string>) {
288+
export function updateSignaturesFromCache(state: BuilderState, signatureCache: ESMap<Path, string>) {
289289
signatureCache.forEach((signature, path) => updateSignatureOfFile(state, signature, path));
290290
}
291291

@@ -297,7 +297,7 @@ namespace ts {
297297
/**
298298
* Returns if the shape of the signature has changed since last emit
299299
*/
300-
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: Map<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ComputingExportedModulesMap) {
300+
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ComputingExportedModulesMap) {
301301
Debug.assert(!!sourceFile);
302302
Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
303303

@@ -518,7 +518,7 @@ namespace ts {
518518
/**
519519
* When program emits modular code, gets the files affected by the sourceFile whose shape has changed
520520
*/
521-
function getFilesAffectedByUpdatedShapeWhenModuleEmit(state: BuilderState, programOfThisState: Program, sourceFileWithUpdatedShape: SourceFile, cacheToUpdateSignature: Map<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash | undefined, exportedModulesMapCache: ComputingExportedModulesMap | undefined) {
521+
function getFilesAffectedByUpdatedShapeWhenModuleEmit(state: BuilderState, programOfThisState: Program, sourceFileWithUpdatedShape: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash | undefined, exportedModulesMapCache: ComputingExportedModulesMap | undefined) {
522522
if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
523523
return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
524524
}

0 commit comments

Comments
 (0)