Skip to content

Commit

Permalink
docs: fix svg type override (#12078)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Feb 16, 2023
1 parent 05b3df0 commit f2a5fcc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions docs/guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,22 @@ This will provide the following type shims:
- Types for the [HMR API](./api-hmr) on `import.meta.hot`

::: tip
To override the default typing, declare it before the triple-slash reference. For example, to make the default import of `*.svg` a React component:
To override the default typing, add a type definition file that contains your typings. Then, add the type reference before `vite/client`.

```ts
declare module '*.svg' {
const content: React.FC<React.SVGProps<SVGElement>>
export default content
}
For example, to make the default import of `*.svg` a React component:

/// <reference types="vite/client" />
```
- `vite-env-override.d.ts` (the file that contains your typings):
```ts
declare module '*.svg' {
const content: React.FC<React.SVGProps<SVGElement>>
export default content
}
```
- The file containing the reference to `vite/client`:
```ts
/// <reference types="./vite-env-override.d.ts" />
/// <reference types="vite/client" />
```

:::

Expand Down

0 comments on commit f2a5fcc

Please sign in to comment.