mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
Make createMapLike private and rename to createDictionaryObject
This commit is contained in:
@@ -762,7 +762,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function serializeCompilerOptions(options: CompilerOptions): MapLike<CompilerOptionsValue> {
|
||||
const result = createMapLike<CompilerOptionsValue>();
|
||||
const result: ts.MapLike<CompilerOptionsValue> = {};
|
||||
const optionsNameMap = getOptionNameMap().optionNameMap;
|
||||
|
||||
for (const name in options) {
|
||||
@@ -1302,7 +1302,7 @@ namespace ts {
|
||||
// /a/b/a?z - Watch /a/b directly to catch any new file matching a?z
|
||||
const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude");
|
||||
const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
|
||||
const wildcardDirectories = createMapLike<WatchDirectoryFlags>();
|
||||
const wildcardDirectories: ts.MapLike<WatchDirectoryFlags> = {};
|
||||
if (include !== undefined) {
|
||||
const recursiveKeys: string[] = [];
|
||||
for (const file of include) {
|
||||
@@ -1325,7 +1325,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Remove any subpaths under an existing recursively watched directory.
|
||||
for (const key in wildcardDirectories) {
|
||||
for (const key in wildcardDirectories) if (hasProperty(wildcardDirectories, key)) {
|
||||
for (const recursiveKey of recursiveKeys) {
|
||||
if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
|
||||
delete wildcardDirectories[key];
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace ts {
|
||||
// More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times.
|
||||
export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined;
|
||||
|
||||
/** Create a MapLike with good performance. Prefer this over a literal `{}`. */
|
||||
export function createMapLike<T>(): MapLike<T> {
|
||||
/** Create a MapLike with good performance. */
|
||||
function createDictionaryObject<T>(): MapLike<T> {
|
||||
const map = Object.create(null); // tslint:disable-line:no-null-keyword
|
||||
|
||||
// Using 'delete' on an object causes V8 to put the object in dictionary mode.
|
||||
@@ -39,7 +39,7 @@ namespace ts {
|
||||
return map;
|
||||
}
|
||||
|
||||
export const sparseArray: <T>() => SparseArray<T> = createMapLike;
|
||||
export const sparseArray: <T>() => SparseArray<T> = createDictionaryObject;
|
||||
|
||||
/** Create a new map. If a template object is provided, the map will copy entries from it. */
|
||||
export function createMap<T>(template?: MapLike<T>): Map<T> {
|
||||
@@ -85,7 +85,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
return class<T> implements Map<T> {
|
||||
private data = createMapLike<T>();
|
||||
private data = createDictionaryObject<T>();
|
||||
public size = 0;
|
||||
|
||||
get(key: string): T {
|
||||
@@ -115,7 +115,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.data = createMapLike<T>();
|
||||
this.data = createDictionaryObject<T>();
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace Harness.LanguageService {
|
||||
this.getModuleResolutionsForFile = (fileName) => {
|
||||
const scriptInfo = this.getScriptInfo(fileName);
|
||||
const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true);
|
||||
const imports = ts.createMapLike<string>();
|
||||
const imports: ts.MapLike<string> = {};
|
||||
for (const module of preprocessInfo.importedFiles) {
|
||||
const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost);
|
||||
if (resolutionInfo.resolvedModule) {
|
||||
@@ -275,7 +275,7 @@ namespace Harness.LanguageService {
|
||||
const scriptInfo = this.getScriptInfo(fileName);
|
||||
if (scriptInfo) {
|
||||
const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false);
|
||||
const resolutions = ts.createMapLike<ts.ResolvedTypeReferenceDirective>();
|
||||
const resolutions: ts.MapLike<ts.ResolvedTypeReferenceDirective> = {};
|
||||
const settings = this.nativeHost.getCompilationSettings();
|
||||
for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) {
|
||||
const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost);
|
||||
|
||||
Reference in New Issue
Block a user