fix: accept readonly arrays in LogTopic type#4455
Open
Conversation
|
@nikicat is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
|
LogTopic now includes `readonly Hex[]` so that `as const` and readonly arrays are assignable to topic filters without type errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40034a0 to
729e91c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LogTopicis changed fromHex | Hex[] | nulltoHex | readonly Hex[] | null. Sincereadonly T[]is a supertype ofT[], this accepts both mutable and readonly arrays.LogTopicTypeconditional is updated correspondingly: it now matchesreadonly Hex[](which includesHex[]) and producesreadonly primitiveType[].Motivation
TypeScript's
readonly T[]is not assignable toT[]. Users who define topic arrays withas constor receive them from functions returning readonly arrays get type errors when passing them togetLogs,createEventFilter,watchEvent, etc.Log topic filters are read-only by nature — they're passed to JSON-RPC calls and never mutated — so accepting readonly arrays is both correct and expected.
This is a non-breaking change: all existing mutable-array code continues to work since
T[]is assignable toreadonly T[].Related discussions
topicstype narrowingTest plan
🤖 Generated with Claude Code