feat(icon): add type support for local SVG collection#360
Closed
CRBroughton wants to merge 2 commits intonuxt:mainfrom
Closed
feat(icon): add type support for local SVG collection#360CRBroughton wants to merge 2 commits intonuxt:mainfrom
CRBroughton wants to merge 2 commits intonuxt:mainfrom
Conversation
6 tasks
Member
|
Thank you for your PR. But I feel this would be better to be handled on the IDE side, via something like https://github.com/antfu/vscode-iconify. Injecting .d.ts in this case is a bit too fragile and not very reliable. Thank you. |
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
resolves #359
❓ Type of change
📚 Description
This PR enhances the existing custom SVG collections feature by adding TypeScript type generation. Currently, when using custom SVG collections, developers don't get type safety or autocompletion for their icon names. This PR adds automatic type generation that creates TypeScript definitions for all SVGs in custom collections.
Current Behavior
New Behavior
Example configuration:
I've tested this with the included SVGs in the repository. Please let me know if you'd like me to make any adjustments; The only downside I can see right now is that if you have both local and non-local collections in use, you can't make use of the feature; There might be a way for us to widen the type if both local collections and other collections are in use at the same time.
Edit: Just reading through my own PR again; I think renaming the 'generateTypes' key to something like 'generateLocalSVGTypes' might be better for the user, as it's only going to work with local types, and the existing name might be misleading or confusing. Can change this tomorrow though if there's agreement.
Edit II: Changed the name to generateLocalSVGTypes