(
config: T & Partial<{format: FormatConfig}>,
)
| 15 | |
| 16 | /** Retrieve and validate the config as `FormatConfig`. */ |
| 17 | export function assertValidFormatConfig<T extends NgDevConfig>( |
| 18 | config: T & Partial<{format: FormatConfig}>, |
| 19 | ): asserts config is T & {format: FormatConfig} { |
| 20 | // List of errors encountered validating the config. |
| 21 | const errors: string[] = []; |
| 22 | if (config.format === undefined) { |
| 23 | throw new ConfigValidationError(`No configuration defined for "format"`); |
| 24 | } |
| 25 | |
| 26 | for (const [key, value] of Object.entries(config.format!)) { |
| 27 | if (typeof value !== 'boolean') { |
| 28 | errors.push(`"format.${key}" is not a boolean`); |
| 29 | } |
| 30 | } |
| 31 | if (errors.length) { |
| 32 | throw new ConfigValidationError('Invalid "format" configuration', errors); |
| 33 | } |
| 34 | } |
no test coverage detected