export type LeafType = '' & { readonly __tag: unique symbol } export interface RadixTree extends Map> { // Distinguish between an empty string indicating a leaf node and a non-empty // string indicating a subtree. Overriding these types avoids a lot of type // assertions elsewhere in the code. It is not 100% foolproof because you can // still pass in a blank string '' disguised as `string` and potentially get a // leaf value. get(key: LeafType): T | undefined get(key: string): RadixTree | undefined set(key: LeafType, value: T): this set(key: string, value: RadixTree): this } export type Entry = [string, T] export type Path = [RadixTree | undefined, string][]