(parsedConfigFile: ts.ParsedCommandLine)
| 107 | ]; |
| 108 | |
| 109 | export function updateParsedConfigFile(parsedConfigFile: ts.ParsedCommandLine): ParsedCommandLine { |
| 110 | let hasRootLevelOptions = false; |
| 111 | for (const [name, rawValue] of Object.entries(parsedConfigFile.raw)) { |
| 112 | const option = optionDeclarations.find(option => option.name === name); |
| 113 | if (!option) continue; |
| 114 | |
| 115 | if (parsedConfigFile.raw.tstl === undefined) parsedConfigFile.raw.tstl = {}; |
| 116 | parsedConfigFile.raw.tstl[name] = rawValue; |
| 117 | hasRootLevelOptions = true; |
| 118 | } |
| 119 | |
| 120 | if (parsedConfigFile.raw.tstl) { |
| 121 | if (hasRootLevelOptions) { |
| 122 | parsedConfigFile.errors.push(cliDiagnostics.tstlOptionsAreMovingToTheTstlObject(parsedConfigFile.raw.tstl)); |
| 123 | } |
| 124 | |
| 125 | for (const [name, rawValue] of Object.entries(parsedConfigFile.raw.tstl)) { |
| 126 | const option = optionDeclarations.find(option => option.name === name); |
| 127 | if (!option) { |
| 128 | parsedConfigFile.errors.push(cliDiagnostics.unknownCompilerOption(name)); |
| 129 | continue; |
| 130 | } |
| 131 | |
| 132 | const { error, value } = readValue(option, rawValue, OptionSource.TsConfig); |
| 133 | if (error) parsedConfigFile.errors.push(error); |
| 134 | if (parsedConfigFile.options[name] === undefined) parsedConfigFile.options[name] = value; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return parsedConfigFile; |
| 139 | } |
| 140 | |
| 141 | export function parseCommandLine(args: string[]): ParsedCommandLine { |
| 142 | return updateParsedCommandLine(ts.parseCommandLine(args), args); |
no test coverage detected