Type Alias: X12FatalCode
X12FatalCode = typeof
FATAL_CODES[keyof typeofFATAL_CODES]
Discriminant type for X12ParseError.code. Narrowing a caught error 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 FATAL_CODES registry.
Example
import type { X12FatalCode } from "@cosyte/x12";
function describe(code: X12FatalCode): string {
switch (code) {
case "X12_EMPTY_INPUT":
return "input was empty";
case "X12_NO_ISA_HEADER":
return "missing ISA";
case "X12_ISA_TOO_SHORT":
return "ISA truncated";
case "X12_INVALID_DELIMITERS":
return "bad ISA delimiters";
}
}