From 4bc2314cbe6092257a2948525311e8e7a9f27223 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 4 May 2016 14:50:58 -0700 Subject: [PATCH 1/4] Add propertybag to parsed tsconfig.json file. This allows consumers of the LS to read properties added to the tsconfig.json without having to worry about dealing with comments. --- src/compiler/commandLineParser.ts | 17 +++++++++++++++++ src/compiler/types.ts | 1 + src/services/shims.ts | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index c53e2fcc2e..518d7a2a1f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -664,6 +664,22 @@ namespace ts { const compilerOptions: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); const options = extend(existingOptions, compilerOptions); const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + + // Contains the properties on the json we don't recognize, but the + // host might so we return them as a property bag. This allows the host to handle + // them, but doesn't have to deal with removing comments from the source json. + const other: any = {}; + + const knownProperties = ["compilerOptions", "typingOptions", "files", "exclude"]; + + for (const prop in json) { + if (knownProperties.indexOf(prop) >= 0) { + continue; + } + + other[prop] = json[prop]; + } + options.configFilePath = configFileName; const fileNames = getFileNames(errors); @@ -672,6 +688,7 @@ namespace ts { options, fileNames, typingOptions, + other, errors }; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d0d411a710..aede79fe23 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2592,6 +2592,7 @@ namespace ts { options: CompilerOptions; typingOptions?: TypingOptions; fileNames: string[]; + other?: any; errors: Diagnostic[]; } diff --git a/src/services/shims.ts b/src/services/shims.ts index b849407eba..21f2454d7c 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -997,6 +997,7 @@ namespace ts { options: {}, typingOptions: {}, files: [], + other: {}, errors: [realizeDiagnostic(result.error, "\r\n")] }; } @@ -1008,6 +1009,7 @@ namespace ts { options: configFile.options, typingOptions: configFile.typingOptions, files: configFile.fileNames, + other: configFile.other, errors: realizeDiagnostics(configFile.errors, "\r\n") }; }); From c866996f30cea161a2b23a8fcde6cf557c27b04c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 4 May 2016 16:17:08 -0700 Subject: [PATCH 2/4] CR Feedback --- src/compiler/commandLineParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 518d7a2a1f..338200b5d1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -673,7 +673,7 @@ namespace ts { const knownProperties = ["compilerOptions", "typingOptions", "files", "exclude"]; for (const prop in json) { - if (knownProperties.indexOf(prop) >= 0) { + if (ts.indexOf(knownProperties, prop) >= 0) { continue; } From 8aff38e12863200d8c4a22dbc7bec2155c2e610a Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 6 May 2016 10:12:12 -0700 Subject: [PATCH 3/4] Add the entire tsconfig as a raw property to the parsed config. --- src/compiler/commandLineParser.ts | 17 +---------------- src/compiler/types.ts | 2 +- src/services/shims.ts | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 338200b5d1..92b2a35f42 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -665,21 +665,6 @@ namespace ts { const options = extend(existingOptions, compilerOptions); const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); - // Contains the properties on the json we don't recognize, but the - // host might so we return them as a property bag. This allows the host to handle - // them, but doesn't have to deal with removing comments from the source json. - const other: any = {}; - - const knownProperties = ["compilerOptions", "typingOptions", "files", "exclude"]; - - for (const prop in json) { - if (ts.indexOf(knownProperties, prop) >= 0) { - continue; - } - - other[prop] = json[prop]; - } - options.configFilePath = configFileName; const fileNames = getFileNames(errors); @@ -688,7 +673,7 @@ namespace ts { options, fileNames, typingOptions, - other, + raw: json, errors }; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index aede79fe23..7a850a2270 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2592,7 +2592,7 @@ namespace ts { options: CompilerOptions; typingOptions?: TypingOptions; fileNames: string[]; - other?: any; + raw?: any; errors: Diagnostic[]; } diff --git a/src/services/shims.ts b/src/services/shims.ts index 21f2454d7c..6fbc86d9fc 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1009,7 +1009,7 @@ namespace ts { options: configFile.options, typingOptions: configFile.typingOptions, files: configFile.fileNames, - other: configFile.other, + raw: configFile.raw, errors: realizeDiagnostics(configFile.errors, "\r\n") }; }); From 88da665dff94c85e38f174475f28a257b7e6cab9 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 6 May 2016 10:27:58 -0700 Subject: [PATCH 4/4] CR Feedback --- src/services/shims.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 6fbc86d9fc..ce714b91c5 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -997,7 +997,7 @@ namespace ts { options: {}, typingOptions: {}, files: [], - other: {}, + raw: {}, errors: [realizeDiagnostic(result.error, "\r\n")] }; }