diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70827becffe..a312f91c8f6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23552,7 +23552,7 @@ namespace ts { } // Initialize global symbol table - let augmentations: LiteralExpression[][]; + let augmentations: ReadonlyArray[]; for (const file of host.getSourceFiles()) { if (!isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3d63edddac1..f15baeefcdb 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3,7 +3,6 @@ /// namespace ts { - const emptyArray: any[] = []; const ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string { @@ -1390,8 +1389,8 @@ namespace ts { const isExternalModuleFile = isExternalModule(file); // file.imports may not be undefined if there exists dynamic import - let imports: LiteralExpression[]; - let moduleAugmentations: LiteralExpression[]; + let imports: StringLiteral[]; + let moduleAugmentations: StringLiteral[]; let ambientModules: string[]; // If we are importing helpers, we need to add a synthetic reference to resolve the @@ -1426,23 +1425,23 @@ namespace ts { case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.ExportDeclaration: const moduleNameExpr = getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { + if (!moduleNameExpr || !isStringLiteral(moduleNameExpr)) { break; } - if (!(moduleNameExpr).text) { + if (!moduleNameExpr.text) { break; } // TypeScript 1.0 spec (April 2014): 12.1.6 // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. - if (!inAmbientModule || !isExternalModuleNameRelative((moduleNameExpr).text)) { - (imports || (imports = [])).push(moduleNameExpr); + if (!inAmbientModule || !isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); } break; case SyntaxKind.ModuleDeclaration: if (isAmbientModule(node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) { - const moduleName = (node).name; + const moduleName = (node).name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: // - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e16ee34b01a..0d8041220b0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2321,10 +2321,10 @@ namespace ts { // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead /* @internal */ resolvedModules: Map; /* @internal */ resolvedTypeReferenceDirectiveNames: Map; - /* @internal */ imports: StringLiteral[]; - /* @internal */ moduleAugmentations: StringLiteral[]; + /* @internal */ imports: ReadonlyArray; + /* @internal */ moduleAugmentations: ReadonlyArray; /* @internal */ patternAmbientModules?: PatternAmbientModule[]; - /* @internal */ ambientModuleNames: string[]; + /* @internal */ ambientModuleNames: ReadonlyArray; /* @internal */ checkJsDirective: CheckJsDirective | undefined; } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 00ab0165805..71e6bc00b00 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -1,8 +1,6 @@ /// /* @internal */ namespace ts.SignatureHelp { - const emptyArray: any[] = []; - export const enum ArgumentListKind { TypeArguments, CallArguments,