From 4997846e453aa3f74dedf6a1b7aba6494c284177 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Wed, 29 Jul 2026 20:58:28 +0800 Subject: [PATCH] refactor(hooks): simplify regex pool entry --- packages/hooks/hook-protocol/src/matcher.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hooks/hook-protocol/src/matcher.ts b/packages/hooks/hook-protocol/src/matcher.ts index 7d6de5ca06..3cfca019c3 100644 --- a/packages/hooks/hook-protocol/src/matcher.ts +++ b/packages/hooks/hook-protocol/src/matcher.ts @@ -14,8 +14,8 @@ import type { RRegex as RustRegex } from 'rregex' import type { MatcherMode } from './types.ts' type CodexRegexPoolEntry = - | { regex: RustRegex; diagnostic?: never } - | { regex?: never; diagnostic: string } + | { regex: RustRegex } + | { diagnostic: string } type RRegexModule = { RRegex: new(pattern: string) => RustRegex @@ -98,7 +98,7 @@ function compileMatcher(matcher: string | undefined, mode: MatcherMode): Compile if (mode === 'codex') { const entry = internCodexRegex(pattern) - if (entry.regex !== undefined) { + if ('regex' in entry) { const regex = entry.regex return { matches: query => regex.isMatch(query) } }