nl_tokens: Parse the contents of a config file ( tsconfig . json ) .
pl_tokens: function parseJsonConfigFileContent ( json , host , basePath ) { var errors = [ ] ; return { options : getCompilerOptions ( ) , fileNames : getFileNames ( ) , errors : errors } ; function getCompilerOptions ( ) { var options = { } ; var optionNameMap = { } ; ts . forEach ( ts . optionDeclarations , function ( option ) { optionNameMap [ option . name ] = option ; } ) ; var jsonOptions = json [ "compilerOptions" ] ; if ( jsonOptions ) { for ( var id in jsonOptions ) { if ( ts . hasProperty ( optionNameMap , id ) ) { var opt = optionNameMap [ id ] ; var optType = opt . type ; var value = jsonOptions [ id ] ; var expectedType = typeof optType === "string" ? optType : "string" ; if ( typeof value === expectedType ) { if ( typeof optType !== "string" ) { var key = value . toLowerCase ( ) ; if ( ts . hasProperty ( optType , key ) ) { value = optType [ key ] ; } else { errors . push ( ts . createCompilerDiagnostic ( opt . error ) ) ; value = 0 ; } } if ( opt . isFilePath ) { value = ts . normalizePath ( ts . combinePaths ( basePath , value ) ) ; if ( value === "" ) { value = "." ; } } options [ opt . name ] = value ; } else { errors . push ( ts . createCompilerDiagnostic ( ts . Diagnostics . Compiler_option_0_requires_a_value_of_type_1 , id , expectedType ) ) ; } } else { errors . push ( ts . createCompilerDiagnostic ( ts . Diagnostics . Unknown_compiler_option_0 , id ) ) ; } } } return options ; } function getFileNames ( ) { var fileNames = [ ] ; if ( ts . hasProperty ( json , "files" ) ) { if ( json [ "files" ] instanceof Array ) { fileNames = ts . <mask> ( json [ "files" ] , function ( s ) { return ts . combinePaths ( basePath , s ) ; } ) ; } else { errors . push ( ts . createCompilerDiagnostic ( ts . Diagnostics . Compiler_option_0_requires_a_value_of_type_1 , "files" , "Array" ) ) ; } } else { var exclude = json [ "exclude" ] instanceof Array ? ts . map ( json [ "exclude" ] , ts . normalizeSlashes ) : undefined ; var sysFiles = host . readDirectory ( basePath , ".ts" , exclude ) . concat ( host . readDirectory ( basePath , ".tsx" , exclude ) ) ; for ( var i = 0 ; i < sysFiles . length ; i ++ ) { var name_28 = sysFiles [ i ] ; if ( ts . fileExtensionIs ( name_28 , ".d.ts" ) ) { var baseName = name_28 . substr ( 0 , name_28 . length - ".d.ts" . length ) ; if ( ! ts . contains ( sysFiles , baseName + ".tsx" ) && ! ts . contains ( sysFiles , baseName + ".ts" ) ) { fileNames . push ( name_28 ) ; } } else if ( ts . fileExtensionIs ( name_28 , ".ts" ) ) { if ( ! ts . contains ( sysFiles , name_28 + "x" ) ) { fileNames . push ( name_28 ) ; } } else { fileNames . push ( name_28 ) ; } } } return fileNames ; } }