feat(types): add core-free-icons subpath type shim#5
Open
ramonclaudio wants to merge 2 commits intohugeicons:mainfrom
Open
feat(types): add core-free-icons subpath type shim#5ramonclaudio wants to merge 2 commits intohugeicons:mainfrom
ramonclaudio wants to merge 2 commits intohugeicons:mainfrom
Conversation
c0a7638 to
0ea3f90
Compare
@hugeicons/core-free-icons advertises subpath exports via "./*" but only ships a barrel index.d.ts, so subpath imports resolve at runtime but TS can't find types under node16/nodenext/bundler resolution (see hugeicons#3). Ships an opt-in shim as @hugeicons/react/core-free-icons that declares the wildcard module with IconSvgElement. Consumers reference it once: /// <reference types="@hugeicons/react/core-free-icons" /> Removable when core-free-icons emits per-icon .d.ts files.
0ea3f90 to
6e2854a
Compare
The previous shape pulled IconSvgElement (readonly only) from @hugeicons/react. Switch to the IconSvgObject union (mutable | readonly) that core-free-icons itself uses for its barrel exports, so subpath and barrel imports type identically. HugeiconsIcon still accepts the value either way (mutable arrays are assignable to readonly), so this is consistent only, no behavior change.
e247d8a to
7237e6c
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.
Adds ambient types for
@hugeicons/core-free-iconssubpath imports that auto-load when@hugeicons/reactis installed.The icon package advertises subpath exports via
"./*"butdist/types/only ships the barrelindex.d.ts, so subpath imports resolve at runtime but TypeScript can't find types undernode16/nodenext/bundlerresolution. A project importing 32 icons pays 6.2 MB of pre-bundled JS in dev vs 33 KB for subpath imports. 194× bigger for zero runtime benefit.core-free-iconssource doesn't seem to be public, so@hugeicons/reactis the closest public surface, and it already ownsIconSvgElement.Changes:
src/core-free-icons.d.ts: ambient declaration for@hugeicons/core-free-icons/*typed asIconSvgElementsrc/index.ts: triple-slash path reference so the declaration auto-loadsrollup.config.mjs:copyAmbientTypes()writeBundle hook copies the file intodist/types/and re-injects the reference into the emittedindex.d.ts(rollup-plugin-dts strips reference directives during bundling)README.md:Subpath importsbullet in the Performance listBarrel imports keep working. Verified end-to-end against a TanStack Start project (33 icons,
tsc --noEmitclean with the fork linked and no local shim).Addresses #3.