Skip to content

Commit 0afa459

Browse files
committed
Merge pull request #2563 from Microsoft/exposeConfigFileHelpers
Expose readConfigFile and parseConfigFile
2 parents 4577959 + 18d8fed commit 0afa459

10 files changed

+154
-1
lines changed

Jakefile

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ var definitionsRoots = [
111111
"compiler/parser.d.ts",
112112
"compiler/checker.d.ts",
113113
"compiler/program.d.ts",
114+
"compiler/commandLineParser.d.ts",
114115
"services/services.d.ts",
115116
];
116117

src/compiler/commandLineParser.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/// <reference path="scanner.ts"/>
55

66
module ts {
7+
/* @internal */
78
export var optionDeclarations: CommandLineOption[] = [
89
{
910
name: "charset",
@@ -157,7 +158,8 @@ module ts {
157158
description: Diagnostics.Watch_input_files,
158159
}
159160
];
160-
161+
162+
/* @internal */
161163
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
162164
var options: CompilerOptions = {};
163165
var fileNames: string[] = [];
@@ -267,6 +269,10 @@ module ts {
267269
}
268270
}
269271

272+
/**
273+
* Read tsconfig.json file
274+
* @param fileName The path to the config file
275+
*/
270276
export function readConfigFile(fileName: string): any {
271277
try {
272278
var text = sys.readFile(fileName);
@@ -276,6 +282,12 @@ module ts {
276282
}
277283
}
278284

285+
/**
286+
* Parse the contents of a config file (tsconfig.json).
287+
* @param json The contents of the config file to parse
288+
* @param basePath A root directory to resolve relative path entries in the config
289+
* file to. e.g. outDir
290+
*/
279291
export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine {
280292
var errors: Diagnostic[] = [];
281293

tests/baselines/reference/APISample_compile.js

+14
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,20 @@ declare module "typescript" {
15041504
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
15051505
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
15061506
}
1507+
declare module "typescript" {
1508+
/**
1509+
* Read tsconfig.json file
1510+
* @param fileName The path to the config file
1511+
*/
1512+
function readConfigFile(fileName: string): any;
1513+
/**
1514+
* Parse the contents of a config file (tsconfig.json).
1515+
* @param json The contents of the config file to parse
1516+
* @param basePath A root directory to resolve relative path entries in the config
1517+
* file to. e.g. outDir
1518+
*/
1519+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
1520+
}
15071521
declare module "typescript" {
15081522
/** The version of the language service API */
15091523
let servicesVersion: string;

tests/baselines/reference/APISample_compile.types

+21
Original file line numberDiff line numberDiff line change
@@ -4838,6 +4838,27 @@ declare module "typescript" {
48384838
>CompilerHost : CompilerHost
48394839
>Program : Program
48404840
}
4841+
declare module "typescript" {
4842+
/**
4843+
* Read tsconfig.json file
4844+
* @param fileName The path to the config file
4845+
*/
4846+
function readConfigFile(fileName: string): any;
4847+
>readConfigFile : (fileName: string) => any
4848+
>fileName : string
4849+
4850+
/**
4851+
* Parse the contents of a config file (tsconfig.json).
4852+
* @param json The contents of the config file to parse
4853+
* @param basePath A root directory to resolve relative path entries in the config
4854+
* file to. e.g. outDir
4855+
*/
4856+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
4857+
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
4858+
>json : any
4859+
>basePath : string
4860+
>ParsedCommandLine : ParsedCommandLine
4861+
}
48414862
declare module "typescript" {
48424863
/** The version of the language service API */
48434864
let servicesVersion: string;

tests/baselines/reference/APISample_linter.js

+14
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,20 @@ declare module "typescript" {
15351535
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
15361536
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
15371537
}
1538+
declare module "typescript" {
1539+
/**
1540+
* Read tsconfig.json file
1541+
* @param fileName The path to the config file
1542+
*/
1543+
function readConfigFile(fileName: string): any;
1544+
/**
1545+
* Parse the contents of a config file (tsconfig.json).
1546+
* @param json The contents of the config file to parse
1547+
* @param basePath A root directory to resolve relative path entries in the config
1548+
* file to. e.g. outDir
1549+
*/
1550+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
1551+
}
15381552
declare module "typescript" {
15391553
/** The version of the language service API */
15401554
let servicesVersion: string;

tests/baselines/reference/APISample_linter.types

+21
Original file line numberDiff line numberDiff line change
@@ -4984,6 +4984,27 @@ declare module "typescript" {
49844984
>CompilerHost : CompilerHost
49854985
>Program : Program
49864986
}
4987+
declare module "typescript" {
4988+
/**
4989+
* Read tsconfig.json file
4990+
* @param fileName The path to the config file
4991+
*/
4992+
function readConfigFile(fileName: string): any;
4993+
>readConfigFile : (fileName: string) => any
4994+
>fileName : string
4995+
4996+
/**
4997+
* Parse the contents of a config file (tsconfig.json).
4998+
* @param json The contents of the config file to parse
4999+
* @param basePath A root directory to resolve relative path entries in the config
5000+
* file to. e.g. outDir
5001+
*/
5002+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
5003+
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
5004+
>json : any
5005+
>basePath : string
5006+
>ParsedCommandLine : ParsedCommandLine
5007+
}
49875008
declare module "typescript" {
49885009
/** The version of the language service API */
49895010
let servicesVersion: string;

tests/baselines/reference/APISample_transform.js

+14
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,20 @@ declare module "typescript" {
15361536
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
15371537
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
15381538
}
1539+
declare module "typescript" {
1540+
/**
1541+
* Read tsconfig.json file
1542+
* @param fileName The path to the config file
1543+
*/
1544+
function readConfigFile(fileName: string): any;
1545+
/**
1546+
* Parse the contents of a config file (tsconfig.json).
1547+
* @param json The contents of the config file to parse
1548+
* @param basePath A root directory to resolve relative path entries in the config
1549+
* file to. e.g. outDir
1550+
*/
1551+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
1552+
}
15391553
declare module "typescript" {
15401554
/** The version of the language service API */
15411555
let servicesVersion: string;

tests/baselines/reference/APISample_transform.types

+21
Original file line numberDiff line numberDiff line change
@@ -4934,6 +4934,27 @@ declare module "typescript" {
49344934
>CompilerHost : CompilerHost
49354935
>Program : Program
49364936
}
4937+
declare module "typescript" {
4938+
/**
4939+
* Read tsconfig.json file
4940+
* @param fileName The path to the config file
4941+
*/
4942+
function readConfigFile(fileName: string): any;
4943+
>readConfigFile : (fileName: string) => any
4944+
>fileName : string
4945+
4946+
/**
4947+
* Parse the contents of a config file (tsconfig.json).
4948+
* @param json The contents of the config file to parse
4949+
* @param basePath A root directory to resolve relative path entries in the config
4950+
* file to. e.g. outDir
4951+
*/
4952+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
4953+
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
4954+
>json : any
4955+
>basePath : string
4956+
>ParsedCommandLine : ParsedCommandLine
4957+
}
49374958
declare module "typescript" {
49384959
/** The version of the language service API */
49394960
let servicesVersion: string;

tests/baselines/reference/APISample_watcher.js

+14
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,20 @@ declare module "typescript" {
15731573
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
15741574
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
15751575
}
1576+
declare module "typescript" {
1577+
/**
1578+
* Read tsconfig.json file
1579+
* @param fileName The path to the config file
1580+
*/
1581+
function readConfigFile(fileName: string): any;
1582+
/**
1583+
* Parse the contents of a config file (tsconfig.json).
1584+
* @param json The contents of the config file to parse
1585+
* @param basePath A root directory to resolve relative path entries in the config
1586+
* file to. e.g. outDir
1587+
*/
1588+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
1589+
}
15761590
declare module "typescript" {
15771591
/** The version of the language service API */
15781592
let servicesVersion: string;

tests/baselines/reference/APISample_watcher.types

+21
Original file line numberDiff line numberDiff line change
@@ -5107,6 +5107,27 @@ declare module "typescript" {
51075107
>CompilerHost : CompilerHost
51085108
>Program : Program
51095109
}
5110+
declare module "typescript" {
5111+
/**
5112+
* Read tsconfig.json file
5113+
* @param fileName The path to the config file
5114+
*/
5115+
function readConfigFile(fileName: string): any;
5116+
>readConfigFile : (fileName: string) => any
5117+
>fileName : string
5118+
5119+
/**
5120+
* Parse the contents of a config file (tsconfig.json).
5121+
* @param json The contents of the config file to parse
5122+
* @param basePath A root directory to resolve relative path entries in the config
5123+
* file to. e.g. outDir
5124+
*/
5125+
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
5126+
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
5127+
>json : any
5128+
>basePath : string
5129+
>ParsedCommandLine : ParsedCommandLine
5130+
}
51105131
declare module "typescript" {
51115132
/** The version of the language service API */
51125133
let servicesVersion: string;

0 commit comments

Comments
 (0)