Skip to main content
Version: v0.0.4

Type Alias: WarningCode

WarningCode = typeof WARNING_CODES[keyof typeof WARNING_CODES]

Discriminant type for Hl7ParseWarning.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 { Hl7ParseWarning, WarningCode } from "@cosyte/hl7";
function describe(w: Hl7ParseWarning): string {
const code: WarningCode = w.code;
switch (code) {
case "MLLP_FRAMING_STRIPPED":
return "stripped MLLP framing";
default:
return `warning: ${code}`;
}
}