feat: useHead() type narrowing#627
Merged
Merged
Conversation
Collaborator
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. π€ Generated with Claude Code |
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.
π Linked issue
β Type of change
π Description
Implements discriminated union types for
useHead()input, narrowing types based on discriminator properties.Before / After
Link:
relnarrows available propertiesBefore: all properties available on all links
After: CanonicalLink only has relevant props
Link: preload
asnarrows furtherBefore: imagesrcset available on all preloads
After: imagesrcset only on PreloadImageLink
Link: font preload requires crossorigin
Before: no enforcement
After: PreloadFontLink requires crossorigin
Script:
typenarrows available propertiesBefore: async/defer available on JSON-LD
After: JsonLdScript only has textContent
Script: events only on external scripts
Before: onload on inline scripts
After: InlineScript has no event handlers
Meta: mutual exclusion of name/property/http-equiv/charset
Before: can use name + property together
After: discriminated union prevents this
Summary
relStylesheetLink,PreloadLink,CanonicalLink,IconLink, etc.asPreloadImageLink,PreloadFontLink,PreloadScriptLink, etc.type/srcExternalScript,ModuleScript,JsonLdScript,InlineScript, etc.name/property/http-equiv/charsetNameMeta,PropertyMeta,HttpEquivMeta,CharsetMetaLegacy aliases (
LinkWithoutEvents,ScriptWithoutEvents) preserved viaGenericLink/GenericScript.