Skip to content

Remove ts.{Map,Set,ESMap,Iterator} and associated types #51439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
{ "name": "clearInterval" },
{ "name": "setImmediate" },
{ "name": "clearImmediate" },
{ "name": "performance" },
{ "name": "Iterator" },
{ "name": "Map" },
{ "name": "ReadonlyMap" },
{ "name": "Set" },
{ "name": "ReadonlySet" }
{ "name": "performance" }
]
},
"overrides": [
Expand Down
3 changes: 0 additions & 3 deletions src/cancellationToken/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"module": "commonjs",
"types": [
"node"
],
"lib": [
"es6"
]
},
"include": ["**/*"]
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
createSymbolTable, Debug, Declaration, declarationNameToString, DeleteExpression, DestructuringAssignment,
DiagnosticCategory, DiagnosticMessage, DiagnosticRelatedInformation, Diagnostics, DiagnosticWithLocation,
DoStatement, DynamicNamedDeclaration, ElementAccessChain, ElementAccessExpression, EntityNameExpression,
EnumDeclaration, escapeLeadingUnderscores, ESMap, every, ExportAssignment, exportAssignmentIsAlias,
EnumDeclaration, escapeLeadingUnderscores, every, ExportAssignment, exportAssignmentIsAlias,
ExportDeclaration, ExportSpecifier, Expression, ExpressionStatement, findAncestor, FlowFlags, FlowLabel, FlowNode,
FlowReduceLabel, forEach, forEachChild, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression,
FunctionLikeDeclaration, GetAccessorDeclaration, getAssignedExpandoInitializer, getAssignmentDeclarationKind,
Expand Down Expand Up @@ -45,12 +45,12 @@ import {
isVariableDeclaration, isVariableDeclarationInitializedToBareOrAccessedRequire, isVariableStatement,
JSDocCallbackTag, JSDocClassTag, JSDocEnumTag, JSDocFunctionType, JSDocParameterTag, JSDocPropertyLikeTag,
JSDocSignature, JSDocTypedefTag, JSDocTypeLiteral, JsxAttribute, JsxAttributes, LabeledStatement, length,
LiteralLikeElementAccessExpression, Map, MappedTypeNode, MethodDeclaration, ModifierFlags, ModuleBlock,
LiteralLikeElementAccessExpression, MappedTypeNode, MethodDeclaration, ModifierFlags, ModuleBlock,
ModuleDeclaration, Mutable, NamespaceExportDeclaration, Node, NodeArray, NodeFlags, nodeHasName, nodeIsMissing,
nodeIsPresent, NonNullChain, NonNullExpression, NumericLiteral, objectAllocator, ObjectLiteralExpression,
OptionalChain, ParameterDeclaration, ParenthesizedExpression, Pattern, PatternAmbientModule, perfLogger,
PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessChain, PropertyAccessExpression,
PropertyDeclaration, PropertySignature, removeFileExtension, ReturnStatement, ScriptTarget, Set,
PropertyDeclaration, PropertySignature, removeFileExtension, ReturnStatement, ScriptTarget,
SetAccessorDeclaration, setParent, setParentRecursive, setValueDeclaration, ShorthandPropertyAssignment,
shouldPreserveConstEnums, SignatureDeclaration, skipParentheses, sliceAfter, some, SourceFile, SpreadElement,
Statement, StringLiteral, SwitchStatement, Symbol, SymbolFlags, symbolName, SymbolTable, SyntaxKind, TextRange,
Expand All @@ -76,7 +76,7 @@ interface ActiveLabel {
}

/** @internal */
export function getModuleInstanceState(node: ModuleDeclaration, visited?: ESMap<number, ModuleInstanceState | undefined>): ModuleInstanceState {
export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
if (node.body && !node.body.parent) {
// getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already
setParent(node.body, node);
Expand All @@ -96,7 +96,7 @@ function getModuleInstanceStateCached(node: Node, visited = new Map<number, Modu
return result;
}

function getModuleInstanceStateWorker(node: Node, visited: ESMap<number, ModuleInstanceState | undefined>): ModuleInstanceState {
function getModuleInstanceStateWorker(node: Node, visited: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
// A module is uninstantiated if it contains only
switch (node.kind) {
// 1. interface declarations, type alias declarations
Expand Down Expand Up @@ -168,7 +168,7 @@ function getModuleInstanceStateWorker(node: Node, visited: ESMap<number, ModuleI
return ModuleInstanceState.Instantiated;
}

function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: ESMap<number, ModuleInstanceState | undefined>) {
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map<number, ModuleInstanceState | undefined>) {
const name = specifier.propertyName || specifier.name;
let p: Node | undefined = specifier.parent;
while (p) {
Expand Down
24 changes: 12 additions & 12 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
createBuildInfo, createGetCanonicalFileName, createProgram, CustomTransformers, Debug, Diagnostic,
DiagnosticCategory, DiagnosticMessageChain, DiagnosticRelatedInformation, DiagnosticWithLocation,
EmitAndSemanticDiagnosticsBuilderProgram, EmitOnly, EmitResult, emitSkippedWithNoDiagnostics, emptyArray,
ensurePathIsNonModuleName, ESMap, filterSemanticDiagnostics, forEach, forEachEntry, forEachKey, generateDjb2Hash,
ensurePathIsNonModuleName, filterSemanticDiagnostics, forEach, forEachEntry, forEachKey, generateDjb2Hash,
GetCanonicalFileName, getDirectoryPath, getEmitDeclarations, getNormalizedAbsolutePath, getOptionsNameMap,
getOwnKeys, getRelativePathFromDirectory, getTsBuildInfoEmitOutputFilePath, handleNoEmitOptions, isArray,
isDeclarationFileName, isJsonSourceFile, isNumber, isString, map, Map, mapDefined, maybeBind, noop, notImplemented,
outFile, Path, Program, ProjectReference, ReadBuildProgramHost, ReadonlyCollection, ReadonlyESMap, ReadonlySet,
returnFalse, returnUndefined, SemanticDiagnosticsBuilderProgram, Set, skipTypeChecking, some, SourceFile,
isDeclarationFileName, isJsonSourceFile, isNumber, isString, map, mapDefined, maybeBind, noop, notImplemented,
outFile, Path, Program, ProjectReference, ReadBuildProgramHost, ReadonlyCollection,
returnFalse, returnUndefined, SemanticDiagnosticsBuilderProgram, skipTypeChecking, some, SourceFile,
sourceFileMayBeEmitted, SourceMapEmitResult, toPath, tryAddToSet, WriteFileCallback, WriteFileCallbackData,
} from "./_namespaces/ts";

Expand Down Expand Up @@ -51,7 +51,7 @@ export interface ReusableBuilderProgramState extends BuilderState {
/**
* Cache of bind and check diagnostics for files with their Path being the key
*/
semanticDiagnosticsPerFile?: ESMap<Path, readonly ReusableDiagnostic[] | readonly Diagnostic[]> | undefined;
semanticDiagnosticsPerFile?: Map<Path, readonly ReusableDiagnostic[] | readonly Diagnostic[]> | undefined;
/**
* The map has key by source file's path that has been changed
*/
Expand All @@ -67,7 +67,7 @@ export interface ReusableBuilderProgramState extends BuilderState {
/**
* Files pending to be emitted
*/
affectedFilesPendingEmit?: ReadonlyESMap<Path, BuilderFileEmit>;
affectedFilesPendingEmit?: ReadonlyMap<Path, BuilderFileEmit>;
/**
* emitKind pending for a program with --out
*/
Expand All @@ -79,7 +79,7 @@ export interface ReusableBuilderProgramState extends BuilderState {
/**
* Hash of d.ts emitted for the file, use to track when emit of d.ts changes
*/
emitSignatures?: ESMap<Path, EmitSignature>;
emitSignatures?: Map<Path, EmitSignature>;
/**
* Hash of d.ts emit with --out
*/
Expand Down Expand Up @@ -118,7 +118,7 @@ export interface BuilderProgramState extends BuilderState, ReusableBuilderProgra
/**
* Cache of bind and check diagnostics for files with their Path being the key
*/
semanticDiagnosticsPerFile: ESMap<Path, readonly Diagnostic[]> | undefined;
semanticDiagnosticsPerFile: Map<Path, readonly Diagnostic[]> | undefined;
/**
* The map has key by source file's path that has been changed
*/
Expand Down Expand Up @@ -154,15 +154,15 @@ export interface BuilderProgramState extends BuilderState, ReusableBuilderProgra
/**
* Files pending to be emitted
*/
affectedFilesPendingEmit?: ESMap<Path, BuilderFileEmit>;
affectedFilesPendingEmit?: Map<Path, BuilderFileEmit>;
/**
* true if build info is emitted
*/
buildInfoEmitPending: boolean;
/**
* Already seen emitted files
*/
seenEmittedFiles: ESMap<Path, BuilderFileEmit> | undefined;
seenEmittedFiles: Map<Path, BuilderFileEmit> | undefined;
/** Stores list of files that change signature during emit - test only */
filesChangingSignature?: Set<Path>;
}
Expand Down Expand Up @@ -954,7 +954,7 @@ function getBuildInfo(state: BuilderProgramState, getCanonicalFileName: GetCanon
}

let fileIdsList: (readonly ProgramBuildInfoFileId[])[] | undefined;
let fileNamesToFileIdListId: ESMap<string, ProgramBuildInfoFileIdListId> | undefined;
let fileNamesToFileIdListId: Map<string, ProgramBuildInfoFileIdListId> | undefined;
let emitSignatures: ProgramBuildInfoEmitSignature[] | undefined;
const fileInfos = arrayFrom(state.fileInfos.entries(), ([key, value]): ProgramMultiFileEmitBuildInfoFileInfo => {
// Ensure fileId
Expand Down Expand Up @@ -1733,7 +1733,7 @@ export function getBuildInfoFileVersionMap(
program: ProgramBuildInfo,
buildInfoPath: string,
host: Pick<ReadBuildProgramHost, "useCaseSensitiveFileNames" | "getCurrentDirectory">
): ESMap<Path, string> {
): Map<Path, string> {
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
const fileInfos = new Map<Path, string>();
Expand Down
18 changes: 9 additions & 9 deletions src/compiler/builderState.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
arrayFrom, CancellationToken, computeSignatureWithDiagnostics, CustomTransformers, Debug, EmitOutput, emptyArray,
ESMap, ExportedModulesFromDeclarationEmit, GetCanonicalFileName, getDirectoryPath, getSourceFileOfNode,
ExportedModulesFromDeclarationEmit, GetCanonicalFileName, getDirectoryPath, getSourceFileOfNode,
isDeclarationFileName, isExternalOrCommonJsModule, isGlobalScopeAugmentation, isJsonSourceFile,
isModuleWithStringLiteralName, isStringLiteral, Iterator, Map, mapDefined, mapDefinedIterator, ModuleDeclaration,
ModuleKind, outFile, OutputFile, Path, Program, ReadonlySet, Set, some, SourceFile, StringLiteralLike, Symbol,
isModuleWithStringLiteralName, isStringLiteral, mapDefined, mapDefinedIterator, ModuleDeclaration,
ModuleKind, outFile, OutputFile, Path, Program, some, SourceFile, StringLiteralLike, Symbol,
toPath, TypeChecker,
} from "./_namespaces/ts";

Expand All @@ -23,7 +23,7 @@ export interface BuilderState {
/**
* Information of the file eg. its version, signature etc
*/
fileInfos: ESMap<Path, BuilderState.FileInfo>;
fileInfos: Map<Path, BuilderState.FileInfo>;
/**
* Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled
* Otherwise undefined
Expand Down Expand Up @@ -52,11 +52,11 @@ export interface BuilderState {
/**
* Stores signatures before before the update till affected file is commited
*/
oldSignatures?: ESMap<Path, string | false>;
oldSignatures?: Map<Path, string | false>;
/**
* Stores exportedModulesMap before the update till affected file is commited
*/
oldExportedModulesMap?: ESMap<Path, ReadonlySet<Path> | false>;
oldExportedModulesMap?: Map<Path, ReadonlySet<Path> | false>;
/**
* Cache of all files excluding default library file for the current program
*/
Expand Down Expand Up @@ -90,7 +90,7 @@ export namespace BuilderState {
}

export function createManyToManyPathMap(): ManyToManyPathMap {
function create(forward: ESMap<Path, ReadonlySet<Path>>, reverse: ESMap<Path, Set<Path>>, deleted: Set<Path> | undefined): ManyToManyPathMap {
function create(forward: Map<Path, ReadonlySet<Path>>, reverse: Map<Path, Set<Path>>, deleted: Set<Path> | undefined): ManyToManyPathMap {
const map: ManyToManyPathMap = {
getKeys: v => reverse.get(v),
getValues: k => forward.get(k),
Expand Down Expand Up @@ -136,7 +136,7 @@ export namespace BuilderState {
return create(new Map<Path, Set<Path>>(), new Map<Path, Set<Path>>(), /*deleted*/ undefined);
}

function addToMultimap<K, V>(map: ESMap<K, Set<V>>, k: K, v: V): void {
function addToMultimap<K, V>(map: Map<K, Set<V>>, k: K, v: V): void {
let set = map.get(k);
if (!set) {
set = new Set<V>();
Expand All @@ -145,7 +145,7 @@ export namespace BuilderState {
set.add(v);
}

function deleteFromMultimap<K, V>(map: ESMap<K, Set<V>>, k: K, v: V): boolean {
function deleteFromMultimap<K, V>(map: Map<K, Set<V>>, k: K, v: V): boolean {
const set = map.get(k);

if (set?.delete(v)) {
Expand Down
Loading