Skip to content

Commit cc67dd8

Browse files
committed
Reuse PrioritizedRouteEntry as the Trie entry constraint
`Trie` declared its own `TrieEntry` interface with the same four fields (`index`, `initialLiteralPrefix`, `literalLength`, `variableCount`) as `PrioritizedRouteEntry` from *./priority.ts*. The duplicate would drift if the priority schema gained a field, since trie callers and priority helpers are already constrained together. Drop the local interface and tighten the class generic to `PrioritizedRouteEntry` so the trie and the ordering helpers share a single source of truth. Reported by CodeRabbit in #758 (2026-05-11). Assisted-by: Claude Opus 4.7 (1M context)
1 parent 996a371 commit cc67dd8

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

  • packages/uri-template/src/router

packages/uri-template/src/router/trie.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import type { Path } from "../types.ts";
22
import Node from "./node.ts";
3-
4-
interface TrieEntry {
5-
readonly index: number;
6-
readonly initialLiteralPrefix: string;
7-
readonly literalLength: number;
8-
readonly variableCount: number;
9-
}
3+
import type { PrioritizedRouteEntry } from "./priority.ts";
104

115
/**
126
* Prefix trie for registered route candidates.
137
*/
14-
export default class Trie<TEntry extends TrieEntry> {
8+
export default class Trie<TEntry extends PrioritizedRouteEntry> {
159
readonly #root = new Node<TEntry>();
1610
#dirty = true;
1711

0 commit comments

Comments
 (0)