Skip to content

Commit 0669c85

Browse files
committed
Export libMap so API users can get lib.d.ts listing
1 parent 2234d07 commit 0669c85

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

src/compiler/commandLineParser.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,8 @@ export const libs = libEntries.map(entry => entry[0]);
235235
/**
236236
* A map of lib names to lib files. This map is used both for parsing the "lib" command line
237237
* option as well as for resolving lib reference directives.
238-
*
239-
* @internal
240238
*/
241-
export const libMap = new Map(libEntries);
239+
export const libMap: ReadonlyMap<string, string> = new Map(libEntries);
242240

243241
// Watch related options
244242
/** @internal */
@@ -2524,7 +2522,7 @@ function matchesSpecs(path: string, includeSpecs: readonly string[] | undefined,
25242522
return returnTrue;
25252523
}
25262524

2527-
function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map<string, string | number> | undefined {
2525+
function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): ReadonlyMap<string, string | number> | undefined {
25282526
switch (optionDefinition.type) {
25292527
case "string":
25302528
case "number":
@@ -2541,7 +2539,7 @@ function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption
25412539
}
25422540

25432541
/** @internal */
2544-
export function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: Map<string, string | number>): string | undefined {
2542+
export function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: ReadonlyMap<string, string | number>): string | undefined {
25452543
// There is a typeMap associated with this command-line option so use it to map value back to its name
25462544
return forEachEntry(customTypeMap, (mapValue, key) => {
25472545
if (mapValue === value) {

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7370,7 +7370,7 @@ export interface CreateProgramOptions {
73707370
/** @internal */
73717371
export interface CommandLineOptionBase {
73727372
name: string;
7373-
type: "string" | "number" | "boolean" | "object" | "list" | "listOrElement" | Map<string, number | string>; // a value of a primitive type, or an object literal mapping named values to actual values
7373+
type: "string" | "number" | "boolean" | "object" | "list" | "listOrElement" | ReadonlyMap<string, number | string>; // a value of a primitive type, or an object literal mapping named values to actual values
73747374
isFilePath?: boolean; // True if option value is a path or fileName
73757375
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
73767376
description?: DiagnosticMessage; // The message describing what the command line switch does.
@@ -7414,7 +7414,7 @@ export interface CommandLineOptionOfBooleanType extends CommandLineOptionBase {
74147414

74157415
/** @internal */
74167416
export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
7417-
type: Map<string, number | string>; // an object literal mapping named values to actual values
7417+
type: ReadonlyMap<string, number | string>; // an object literal mapping named values to actual values
74187418
defaultValueDescription: number | string | undefined | DiagnosticMessage;
74197419
deprecatedKeys?: Set<string>;
74207420
}

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9239,6 +9239,11 @@ declare namespace ts {
92399239
options: TypeAcquisition;
92409240
errors: Diagnostic[];
92419241
};
9242+
/**
9243+
* A map of lib names to lib files. This map is used both for parsing the "lib" command line
9244+
* option as well as for resolving lib reference directives.
9245+
*/
9246+
const libMap: ReadonlyMap<string, string>;
92429247
type DiagnosticReporter = (diagnostic: Diagnostic) => void;
92439248
/**
92449249
* Reports config file diagnostics

tests/baselines/reference/api/typescript.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5193,6 +5193,11 @@ declare namespace ts {
51935193
options: TypeAcquisition;
51945194
errors: Diagnostic[];
51955195
};
5196+
/**
5197+
* A map of lib names to lib files. This map is used both for parsing the "lib" command line
5198+
* option as well as for resolving lib reference directives.
5199+
*/
5200+
const libMap: ReadonlyMap<string, string>;
51965201
type DiagnosticReporter = (diagnostic: Diagnostic) => void;
51975202
/**
51985203
* Reports config file diagnostics

0 commit comments

Comments
 (0)