Type Alias: WarningCode
WarningCode = typeof
WARNING_CODES[keyof typeofWARNING_CODES]
Discriminant type for CcdaWarning.code. Narrowing a warning by this code
lets consumers write exhaustive switch blocks (enabled by the
switch-exhaustiveness-check lint rule) and guarantees a typo-free
comparison against the WARNING_CODES registry.
Example
import type { CcdaWarning, WarningCode } from "@cosyte/ccda";
function describe(w: CcdaWarning): string {
const code: WarningCode = w.code;
switch (code) {
case "UNKNOWN_DOCUMENT_TEMPLATE":
return "unrecognized document type";
default:
return `warning: ${code}`;
}
}