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
Add possible to override type of '*.svg' #30060
Changes from 1 commit
704304b
39481b8
f939ea7
a67f150
c18010c
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 |
---|---|---|
|
@@ -16,11 +16,30 @@ declare module '*.png' { | |
|
||
declare module '*.svg' { | ||
/** | ||
* Use `any` to avoid conflicts with | ||
* By default, use `any` to avoid conflicts with | ||
* `@svgr/webpack` plugin or | ||
* `babel-plugin-inline-react-svg` plugin. | ||
* | ||
* If you are not using these plugins, you can override | ||
* the default behavior using a code snippet inside your project | ||
* | ||
* // yourProject/src/global.d.ts | ||
* declare module '*.svg' { | ||
* export interface OverrideDefaultTypeSettings { | ||
* useAny: false; | ||
* } | ||
* } | ||
*/ | ||
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 modify the type when we detect the svg loaders so the user doesn't need to do anything? For example, see #26281 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. I'll try to figure out how this can be done |
||
const content: any | ||
interface DefaultTypeSettings { | ||
useAny: true; | ||
} | ||
|
||
export interface OverrideDefaultTypeSettings {} | ||
|
||
type TypeSettings = Omit<DefaultTypeSettings, keyof OverrideDefaultTypeSettings> & OverrideDefaultTypeSettings; | ||
type ContentType = TypeSettings['useAny'] extends true ? any : StaticImageData; | ||
|
||
const content: ContentType; | ||
|
||
export default content | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We document this as
additional.d.ts
and it needs to be added to the include arrayhttps://nextjs.org/docs/basic-features/typescript