@@ -277,28 +277,6 @@ function getBaseFileName(path: string) {
277
277
return i < 0 ? path : path . substring ( i + 1 ) ;
278
278
}
279
279
280
-
281
- export function parseAndReEmitConfigJSONFile ( content : string ) {
282
- const options : ts . TranspileOptions = {
283
- fileName : "config.js" ,
284
- compilerOptions : {
285
- target : ts . ScriptTarget . Latest ,
286
- removeComments : true
287
- } ,
288
- reportDiagnostics : true
289
- } ;
290
- const { outputText, diagnostics } = ts . transpileModule ( "(" + content + ")" , options ) ;
291
- // Becasue the content was wrapped in "()", the start position of diagnostics needs to be subtract by 1
292
- // also, the emitted result will have "(" in the beginning and ");" in the end. We need to strip these
293
- // as well
294
- const trimmedOutput = outputText . trim ( ) ;
295
- const configJsonObject = JSON . parse ( trimmedOutput . substring ( 1 , trimmedOutput . length - 2 ) ) ;
296
- for ( const diagnostic of diagnostics ) {
297
- diagnostic . start = diagnostic . start - 1 ;
298
- }
299
- return { configJsonObject, diagnostics } ;
300
- }
301
-
302
280
function reduceProperties < T , U > ( map : ts . Map < T > , callback : ( aggregate : U , value : T , key : string ) => U , initial : U ) : U {
303
281
let result = initial ;
304
282
for ( const key in map ) {
@@ -1841,9 +1819,11 @@ export class ProjectService {
1841
1819
// file references will be relative to dirPath (or absolute)
1842
1820
const dirPath = getDirectoryPath ( configFilename ) ;
1843
1821
const contents = this . host . readFile ( configFilename ) ;
1844
- const { configJsonObject, diagnostics } = parseAndReEmitConfigJSONFile ( contents ) ;
1845
- errors = concatenate ( errors , diagnostics ) ;
1846
- const parsedCommandLine = ts . parseJsonConfigFileContent ( configJsonObject , this . host , dirPath , /*existingOptions*/ { } , configFilename ) ;
1822
+ const { config, error} = ts . parseConfigFileTextToJson ( configFilename , contents ) ;
1823
+ if ( error ) {
1824
+ errors . push ( error ) ;
1825
+ }
1826
+ const parsedCommandLine = ts . parseJsonConfigFileContent ( config , this . host , dirPath , /*existingOptions*/ { } , configFilename ) ;
1847
1827
errors = concatenate ( errors , parsedCommandLine . errors ) ;
1848
1828
// Debug.assert(!!parsedCommandLine.fileNames);
1849
1829
0 commit comments