feat(icon): add type support for local SVG collection #360
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