fix: resolve type error in SchemaDisplayPath dangerouslySetInnerHTML#442
Open
moritalous wants to merge 1 commit into
Open
fix: resolve type error in SchemaDisplayPath dangerouslySetInnerHTML#442moritalous wants to merge 1 commit into
moritalous wants to merge 1 commit into
Conversation
children (ReactNode) was passed directly to dangerouslySetInnerHTML's __html, which requires string | TrustedHTML, causing a build-time type error. Render children normally and reserve HTML injection for the default highlighted path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
@moritalous is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
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.
What
SchemaDisplayPathpassedchildren(typed asReactNode) directly todangerouslySetInnerHTML.__html, which requiresstring | TrustedHTML. Thiscaused a build-time TypeScript error under
strict: true, reproducible on afresh, unmodified
create-next-appproject on its very firstnext build.Fixes #441
Why
children ?? highlightedPathcan resolve to anumber,boolean,ReactElement, etc., none of which are assignable to__html. Conceptually,injecting
childrenas raw HTML is also fragile —childrenshould be treatedas a normal React node. This also aligns with the project guideline to avoid
dangerouslySetInnerHTMLunless necessary.How
childrenis provided, render it normally inside the<span>.highlightedPath(astring) is injected viadangerouslySetInnerHTML.Behavior impact
All current usages in this repo render without
children, so there is no behavior change. The only difference is for callers
that previously passed an HTML string as children expecting it to be parsed
as HTML — it is now rendered as text, which is the safer and more idiomatic
React behavior.
Steps to reproduce (before this fix)
Testing
errors in the package are pre-existing and unrelated to this change).