From 5019321e5092f46919b7d1ffb9c7ac3d4fd34db9 Mon Sep 17 00:00:00 2001 From: Luiz Ferraz Date: Tue, 3 Sep 2024 22:24:39 -0300 Subject: [PATCH] feat(astro-when): Use new `injectTypes` utility when available --- .changeset/unlucky-dragons-end.md | 5 +++++ packages/astro-when/src/index.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .changeset/unlucky-dragons-end.md diff --git a/.changeset/unlucky-dragons-end.md b/.changeset/unlucky-dragons-end.md new file mode 100644 index 00000000..4656b684 --- /dev/null +++ b/.changeset/unlucky-dragons-end.md @@ -0,0 +1,5 @@ +--- +'@inox-tools/astro-when': patch +--- + +Inject types in `.astro` folder structure if the utility is available diff --git a/packages/astro-when/src/index.ts b/packages/astro-when/src/index.ts index 1402e5cc..6da39597 100644 --- a/packages/astro-when/src/index.ts +++ b/packages/astro-when/src/index.ts @@ -68,6 +68,16 @@ export default defineIntegration({ }, }); }, + 'astro:config:done': (params) => { + // Check if the version of Astro being used has the `injectTypes` utility. + if (typeof params.injectTypes === 'function') { + debug('Injecting types in .astro structure'); + params.injectTypes({ + filename: 'types.d.ts', + content: "import '@inox-tools/astro-when';", + }); + } + }, }, }), });