From f2a5fccb8cfdd4a8afd54959b5aa54c7958de179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Fri, 17 Feb 2023 00:17:14 +0900 Subject: [PATCH] docs: fix svg type override (#12078) --- docs/guide/features.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/guide/features.md b/docs/guide/features.md index f32da8d1c42d42..9ca69de24ea78a 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -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> - export default content -} +For example, to make the default import of `*.svg` a React component: -/// -``` +- `vite-env-override.d.ts` (the file that contains your typings): + ```ts + declare module '*.svg' { + const content: React.FC> + export default content + } + ``` +- The file containing the reference to `vite/client`: + ```ts + /// + /// + ``` :::