addDts
addDts
allows you to inject a .d.ts
file into the user’s project. It will
create a file inside .astro
and reference it from src/env.d.ts
. For example:
import { defineIntegration } from "astro-integration-kit";import { addDtsPlugin } from "astro-integration-kit/plugins";
export default defineIntegration({ name: "my-integration", plugins: [addDtsPlugin], setup(options) { return { "astro:config:setup": ({ addDts }) => { addDts({ name: "my-integration", content: `declare module "virtual:my-integration" {}` }) } } }})
import type { AstroIntegration } from "astro";import { addDts } from "astro-integration-kit/utilities";
export default function myIntegration(): AstroIntegration { return { name: "my-integration", hooks: { "astro:config:setup": ({ config, logger }) => { addDts({ name: "my-integration", content: `declare module "virtual:my-integration" {}`, root: config.root, srcDir: config.srcDir, logger, }) } } }}