Repository navigation
Export a named SvgComponent type for each target - #23
Merged
Merged
Conversation
Each target now exports its component type as SvgComponent from @svg-jar/plugin/types/<target>, so apps can type a variable or config field that holds an SVG import without writing out the type. The DOM target also exports SvgOptions. The client/<target>.d.ts files stay ambient so the tsconfig "types" setup keeps working, and their *.svg declarations now use the named type. The DOM client no longer declares a global SvgOptions interface. Each test project has a type test that checks SVG imports have the named type and are not any. The Ember test project gets a tsconfig and typecheck script for this. @types/react is now a devDependency of the plugin. Without it, React SVG imports were typed any inside this workspace, and the React runtime is now typed against it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Each target now exports its component type as
SvgComponent, so apps can type a variable, prop or config field that holds an SVG import without writing out the type.Changes
client/<target>-types.d.tsfor all 7 targets, published at@svg-jar/plugin/types/<target>. The DOM file also exportsSvgOptions.client/<target>.d.tsfiles stay ambient, so the tsconfig"types"setup works as before. A.d.tsfile with anexportbecomes a module, and itsdeclare module '*.svg'blocks then stop applying, so the named type lives in a separate file. Importing the type has no global effect, and the*.svgdeclarations still come from the tsconfig entry.SvgOptionsinterface.runtime/react.tsis now typed against@types/react, in the same way the Preact, Vue and Solid runtimes use their framework types. Nothing changes when it runs.SvgComponent.Dependencies
@glint/templateand@types/reactas plugin devDependencies, so the client types resolve inside this workspace. Before this, React SVG imports were typedanyhere because@types/reactcould not be found from the plugin folder.@glint/templateandtypescriptto the Ember test project.Tests
Each test project has a
svg-types.tsthat annotates plain,?unsafe-inlineand?sprite=shapesimports withSvgComponent, plus a@ts-expect-errorcheck that fails if an import is typedany. Each project's custom sprite declaration now uses the named type. The Ember test project has a newtsconfig.jsonandtypecheckscript, so the CI build job'spnpm typecheckcovers it.🤖 Generated with Claude Code