-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(types): add SvgComponent type and update SVG module declaration #13651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': minor | ||
--- | ||
|
||
Add a new SvgComponent type and update SVG module declaration |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import type * as astroHTML from 'astro/jsx-runtime'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Princesseuh do you think this import could have weird TS implications? IIRC its always a bit tricky to import this one (at least in userland) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we import the type from the actual file @florian-lefebvre ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I'm looking at atm but it's tricky because it's only in a namespace inside a dts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So one way is to do
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of exporting the type from here, personally I'd export it directly in client.d.ts, where it's trivial to import from astro-jsx without bundling issues There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want the type to be used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah in which case I think maybe it's fine that way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Princesseuh the way I did it here won't work, as it causes build errors. (I confirmed that I have tried a few different things including "export it directly in client.d.ts" but nothing is working. What exactly did you mean by "it's trivial to import from astro-jsx without bundling issues"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible to fix this? |
||
import type { OmitPreservingIndexSignature, Simplify, WithRequired } from '../type-utils.js'; | ||
import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js'; | ||
import type { ImageService } from './services/service.js'; | ||
|
@@ -284,3 +285,6 @@ export type RemoteImageProps<T> = | |
*/ | ||
inferSize?: false | undefined; | ||
}); | ||
|
||
type SvgProps = astroHTML.JSX.SVGAttributes; | ||
export type SvgComponent = ((props: SvgProps) => any) & ImageMetadata; | ||
florian-lefebvre marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.