diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fcc44ba087f..48a0876d881 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4084,7 +4084,7 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes: SparseArray = []; + const memberTypes: EnumLiteralType[] = []; for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index a326c0c0475..f63094ae16d 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2646,7 +2646,7 @@ namespace ts { return destEmitNode; } - function mergeTokenSourceMapRanges(sourceRanges: SparseArray, destRanges: SparseArray) { + function mergeTokenSourceMapRanges(sourceRanges: TextRange[], destRanges: TextRange[]) { if (!destRanges) destRanges = []; for (const key in sourceRanges) { destRanges[key] = sourceRanges[key]; @@ -3277,7 +3277,7 @@ namespace ts { externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers exportSpecifiers: Map; // export specifiers by name - exportedBindings: SparseArray; // exported names of local declarations + exportedBindings: Identifier[][]; // exported names of local declarations exportedNames: Identifier[]; // all exported names local to module exportEquals: ExportAssignment | undefined; // an export= declaration if one was present hasExportStarsToExportValues: boolean; // whether this module contains export* @@ -3286,7 +3286,7 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; const exportSpecifiers = createMultiMap(); - const exportedBindings: SparseArray = []; + const exportedBindings: Identifier[][] = []; const uniqueExports = createMap(); let exportedNames: Identifier[]; let hasExportDefault = false; @@ -3435,7 +3435,7 @@ namespace ts { } /** Use a sparse array as a multi-map. */ - function multiMapSparseArrayAdd(map: SparseArray, key: number, value: V): V[] { + function multiMapSparseArrayAdd(map: V[][], key: number, value: V): V[] { let values = map[key]; if (values) { values.push(value); diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 8c9da9c4847..7dcfe76a427 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -243,7 +243,7 @@ namespace ts { let currentSourceFile: SourceFile; let renamedCatchVariables: Map; - let renamedCatchVariableDeclarations: SparseArray; + let renamedCatchVariableDeclarations: Identifier[]; let inGeneratorFunctionBody: boolean; let inStatementContainingYield: boolean; diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index b42f4bf4bee..0adea4fd540 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -39,12 +39,12 @@ namespace ts { context.enableSubstitution(SyntaxKind.ShorthandPropertyAssignment); // Substitutes shorthand property assignments for imported/exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap: SparseArray = []; // The ExternalModuleInfo for each file. - const deferredExports: SparseArray = []; // Exports to defer until an EndOfDeclarationMarker is found. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. let currentSourceFile: SourceFile; // The current file. let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file. - let noSubstitution: SparseArray; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index d332f3376b1..3f1488b649d 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -28,10 +28,10 @@ namespace ts { context.enableSubstitution(SyntaxKind.PostfixUnaryExpression); // Substitutes updates to exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap: SparseArray = []; // The ExternalModuleInfo for each file. - const deferredExports: SparseArray = []; // Exports to defer until an EndOfDeclarationMarker is found. - const exportFunctionsMap: SparseArray = []; // The export function associated with a source file. - const noSubstitutionMap: SparseArray> = []; // Set of nodes for which substitution rules should be ignored for each file. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. + const exportFunctionsMap: Identifier[] = []; // The export function associated with a source file. + const noSubstitutionMap: boolean[][] = []; // Set of nodes for which substitution rules should be ignored for each file. let currentSourceFile: SourceFile; // The current file. let moduleInfo: ExternalModuleInfo; // ExternalModuleInfo for the current file. @@ -39,7 +39,7 @@ namespace ts { let contextObject: Identifier; // The context object for the current file. let hoistedStatements: Statement[]; let enclosingBlockScopedContainer: Node; - let noSubstitution: SparseArray; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 96b00434660..e2b8b8fe2ec 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -60,7 +60,7 @@ namespace ts { * A map that keeps track of aliases created for classes with decorators to avoid issues * with the double-binding behavior of classes. */ - let classAliases: SparseArray; + let classAliases: Identifier[]; /** * Keeps track of whether we are within any containing namespaces when performing diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d734998cd7f..2489434c82d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -8,13 +8,6 @@ [index: string]: T; } - /** - * Like MapLike, but keys must be numbers. - */ - export interface SparseArray { - [key: number]: T; - } - /** ES6 Map interface. */ export interface Map { get(key: string): T; @@ -2854,7 +2847,7 @@ // Enum types (TypeFlags.Enum) export interface EnumType extends Type { - memberTypes: SparseArray; + memberTypes: EnumLiteralType[]; } // Enum types (TypeFlags.EnumLiteral) @@ -3684,7 +3677,7 @@ flags?: EmitFlags; // Flags that customize emit commentRange?: TextRange; // The text range to use when emitting leading or trailing comments sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings - tokenSourceMapRanges?: SparseArray; // The text range to use when emitting source mappings for tokens + tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens constantValue?: number; // The constant value of an expression externalHelpersModuleName?: Identifier; // The local name for an imported helpers module helpers?: EmitHelper[]; // Emit helpers for the node diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5e15d97752b..f74c450d61a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3362,7 +3362,7 @@ namespace ts { return false; } - const syntaxKindCache: SparseArray = []; + const syntaxKindCache: string[] = []; export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 82f6ede865f..15c43d9e76b 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -416,7 +416,7 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks: SparseArray<(resp: protocol.Response) => void> = []; + private callbacks: Array<(resp: protocol.Response) => void> = []; private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 4d4873465b5..b2e2eca2951 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -292,7 +292,7 @@ namespace ts.projectSystem { } export class Callbacks { - private map: SparseArray = []; + private map: TimeOutCallback[] = []; private nextId = 1; register(cb: (...args: any[]) => void, args: any[]) { diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index e1e3ef18865..10d0b8eef34 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -16,7 +16,7 @@ namespace ts { } export namespace codefix { - const codeFixes: SparseArray = []; + const codeFixes: CodeFix[][] = []; export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 81b299bf708..8cd0a9664a0 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -14,7 +14,7 @@ namespace ts.codefix { } class ImportCodeActionMap { - private symbolIdToActionMap: SparseArray = []; + private symbolIdToActionMap: ImportCodeAction[][] = []; addAction(symbolId: number, newAction: ImportCodeAction) { if (!newAction) { @@ -125,7 +125,7 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations: SparseArray<(ImportDeclaration | ImportEqualsDeclaration)[]> = []; + const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; let cachedNewImportInsertPosition: number; const allPotentialModules = checker.getAmbientModules();