An element as this library hands one out — what canonicalise produces, and
the type index.ts publishes as AXElement. RawAXElement above is the
internal, open one, and never leaves the package.
Closed on purpose, where the type above is open: no index signature, so a
caller reaching for element.role is told so by the compiler instead of
reading undefined off a field the companion stopped sending. The keys are
DESCRIBE_KEYS plus children, and the two must be changed together —
canonicalise copies exactly the first list, and pruneTree adds the second.
Deliberately a type alias and not an interface. TypeScript gives an object
alias an implicit index signature and an interface none, so this spelling
is what keeps a canonical element assignable back to the open type — every
pure helper in this file takes that one, and a canonical element has to go on
being a legal argument to all of them.
An element as this library hands one out — what
canonicaliseproduces, and the typeindex.tspublishes asAXElement.RawAXElementabove is the internal, open one, and never leaves the package.Closed on purpose, where the type above is open: no index signature, so a caller reaching for
element.roleis told so by the compiler instead of readingundefinedoff a field the companion stopped sending. The keys areDESCRIBE_KEYSpluschildren, and the two must be changed together —canonicalisecopies exactly the first list, andpruneTreeadds the second.Deliberately a type alias and not an interface. TypeScript gives an object alias an implicit index signature and an interface none, so this spelling is what keeps a canonical element assignable back to the open type — every pure helper in this file takes that one, and a canonical element has to go on being a legal argument to all of them.