import { n as LanguageContext, t as CustomLanguage } from "./custom-language-Dbxeg6_y.mjs"; import { t as VueLanguageOptions } from "./vue-C-oo1rxu.mjs"; import { Plugin, RollupError, SourceMapInput } from "rolldown"; import { IsolatedDeclarationsOptions } from "rolldown/experimental"; import { TsconfigJson } from "get-tsconfig"; interface GeneratorResult { /** Generated declaration code. */ code?: string; /** Source map for the generated declaration. */ map?: SourceMapInput; /** Error reported through Rolldown when declaration generation fails. */ error?: RollupError | string; } /** A declaration generator used by the dts plugin. */ interface Generator { /** Initializes resources at the start of each build. */ init?: () => void | Promise; /** Registers transformed source code before declaration generation. */ addFile?: (code: string, fileName: string) => void; /** Generates a declaration for a source file. */ emit: (code: string, fileName: string) => GeneratorResult | Promise; /** Releases resources at the end of each build. */ dispose?: () => void | Promise; /** Invalidates cached state for a changed file in watch mode. */ invalidate?: (fileName: string) => void; } interface Logger { info: (...args: any[]) => void; warn: (...args: any[]) => void; error: (...args: any[]) => void; } interface Options extends DeprecatedOptions { /** * The generator used to produce declaration files. * * - `'tsc'` supports the full TypeScript type system. * - `'oxc'` is faster but requires code compatible with * [`isolatedDeclarations`](https://www.typescriptlang.org/tsconfig/#isolatedDeclarations). * - `'tsgo'` uses the experimental TypeScript Go API. * - `'tsrs'` uses the highly experimental [tsrs](https://github.com/oxc-project/tsrs) * API, a Rust port of TypeScript Go. Only the latest `tsrs` release is * supported. It is never selected automatically. * - A custom {@link Generator} implementation can be provided directly. * * When omitted, the plugin selects `'oxc'` for `isolatedDeclarations`, * `'tsgo'` when TypeScript exposes the declaration emit API or is 7.0 * (deprecated CLI backend), and `'tsc'` otherwise. Volar-based custom languages require `'tsc'`. * * @default Inferred from the TypeScript configuration and installed compiler. */ generator?: "tsc" | "oxc" | "tsgo" | "tsrs" | Generator; /** * Glob pattern(s) that filter which Rolldown entries emit declarations. * * Patterns are relative to {@link cwd} and may be negated with `!`. Only * Rolldown entries are matched; other files never emit declarations. * * Cannot be combined with {@link dtsOnly}; set Rolldown's `input` instead. * * @example * ```ts * entry: ['src/*.ts', '!src/internal/**'] * ``` */ entry?: string | string[]; /** * Base directory for config discovery, glob matching, and relative paths. * * @default process.cwd() */ cwd?: string; /** * Builds declarations only. Each entry resolves to its declaration, so the * build emits no JavaScript. Entries may be source files or existing * declaration files. * * @default false */ dtsOnly?: boolean; /** * A `tsconfig.json` path, resolved relative to {@link cwd}. * * When omitted or `true`, the nearest config is discovered from {@link cwd}. * Set to `false` to disable config loading. The `tsgo` generator requires a * config file, as does `tsrs`. */ tsconfig?: string | boolean; /** * Raw `tsconfig.json` values merged over the loaded config. * The plugin's current `tsgo` implementation does not apply these overrides * to the TypeScript program. */ tsconfigRaw?: Omit; /** * Compiler options merged over those loaded from `tsconfig.json`. * In the plugin's current `tsgo` and `tsrs` implementations, these affect plugin behavior * but do not override the program's compiler options. Set those options in * the config file instead. */ compilerOptions?: TsconfigJson.CompilerOptions; /** * Emits declaration maps (`.d.ts.map`). * With `tsgo` or `tsrs`, source mappings also require `compilerOptions.declarationMap` * to be enabled in the on-disk config; `sourcemap: true` alone is insufficient. * * @default The value of `compilerOptions.declarationMap`. */ sourcemap?: boolean; /** * Resolver used for declaration imports, including packages in `node_modules`. * * Use `'tsc'` when a project depends on TypeScript-specific resolution * behavior; otherwise `'oxc'` is faster. * * @default 'oxc' */ resolver?: "oxc" | "tsc"; /** * Converts a single default export to `export =` for CommonJS consumers. * This does not add support for CommonJS-style declaration input. * * @default false */ cjsDefault?: boolean; /** * Marks declaration modules as having side effects during tree-shaking. * * @default false */ sideEffects?: boolean; /** * Logger used for plugin messages. * * @default console */ logger?: Logger; /** * Generates declarations for JavaScript files with JSDoc types. * * @default Enabled when `allowJs` or `checkJs` is set. */ emitJs?: boolean; /** * Fails the build on type errors. Not supported by `oxc`. * * @default false */ typecheck?: boolean; /** Options for the built-in `tsc` generator. */ tsc?: TscOptions; /** * Options for the `oxc` generator. * * The top-level {@link Options.sourcemap sourcemap} option controls * declaration maps. */ oxc?: Omit; /** * **[Experimental]** Options for the TypeScript Go generator. */ tsgo?: TsgoOptions; /** * **[Highly experimental]** Options for the tsrs generator. * Only the latest `tsrs` release is supported. */ tsrs?: TsrsOptions; /** * Registers non-standard source languages such as Vue or Astro. * * If a language is supported via {@link https://volarjs.dev Volar}, * {@link CustomLanguage.volarTypeScript} and * {@link CustomLanguage.createVolarPlugins} are both required. Volar * languages require `tsc`. Non-Volar languages can use `tsgo` together * with {@link TsgoOptions.vfs `tsgo.vfs`}, or `tsrs` with * {@link TsrsOptions.vfs `tsrs.vfs`}. * * @experimental */ customLanguages?: CustomLanguage[]; } interface DeprecatedOptions { /** @deprecated Use `dtsOnly` instead. */ dtsInput?: boolean; /** @deprecated Use `dtsOnly` instead. */ emitDtsOnly?: boolean; /** @deprecated Use `tsc.build` instead. */ build?: TscOptions["build"]; /** @deprecated Use `tsc.incremental` instead. */ incremental?: TscOptions["incremental"]; /** @deprecated Use `tsc.parallel` instead. */ parallel?: TscOptions["parallel"]; /** @deprecated Use `tsc.eager` instead. */ eager?: TscOptions["eager"]; /** @deprecated Use `tsc.newContext` instead. */ newContext?: TscOptions["newContext"]; /** @deprecated Use `tsc.vue` instead. */ vue?: TscOptions["vue"]; } interface TscOptions { /** * Registers the built-in Vue language integration using `vue-tsc`. * * This is a shortcut for a preconfigured {@link Options.customLanguages} * entry and requires the `tsc` generator. * * @default false */ vue?: boolean | VueLanguageOptions; /** * Uses TypeScript build mode (`tsc -b`) and follows project references. * * @default false */ build?: boolean; /** * Persists build-mode outputs, including `.tsbuildinfo`, to disk for reuse. * When disabled, build outputs stay in memory. * * @default Enabled when the config sets `incremental` or `tsBuildInfoFile`. */ incremental?: boolean; /** * Runs `tsc` or `vue-tsc` in a separate process. * Custom languages supplied through {@link Options.customLanguages} are not * supported in the worker process. * * @default false */ parallel?: boolean; /** * Loads every file listed by `tsconfig.json` into the TypeScript program. * * Useful when one config covers multiple packages or entry points. * * @default false */ eager?: boolean; /** * Uses an isolated TypeScript cache instead of the shared global context. * * @default false */ newContext?: boolean; } interface TsgoOptions { /** * Allows TypeScript to execute content mappers configured in tsconfig. * Cannot be combined with `tsgo.vfs` when content mappers are configured. * * @default false */ runExternalCode?: boolean; /** * A `file://` URL of the TypeScript module that provides the TypeScript Go API. * * Use `import.meta.resolve()` to select an npm alias or another compatible * TypeScript module. * * @default import.meta.resolve('typescript') */ moduleUrl?: string; /** * Path passed to the TypeScript Go API as `tsserverPath`. * With the deprecated TypeScript 7.0 backend, the `tsgo` executable to run. */ path?: string; /** * Supplies Rolldown-transformed source code to the `tsgo` API through a * virtual filesystem. * * @default false */ vfs?: boolean; } interface TsrsOptions { /** * Allows tsrs to execute content mappers configured in tsconfig. * Cannot be combined with `tsrs.vfs` when content mappers are configured. * * @default false */ runExternalCode?: boolean; /** * A `file://` URL of the `tsrs` package module. * * @default import.meta.resolve('tsrs') */ moduleUrl?: string; /** * Path to a custom tsrs executable, passed to the API as `tsserverPath`. */ path?: string; /** * Supplies Rolldown-transformed source code to the tsrs API through a * virtual filesystem. * * @default false */ vfs?: boolean; } type Overwrite = Pick> & U; type OptionsResolved = Overwrite>, { entry?: string[]; tsconfig?: string; oxc: IsolatedDeclarationsOptions; tsconfigRaw: TsconfigJson; tsgo: TsgoOptions; tsrs: TsrsOptions; languageContext: LanguageContext; tsc: Overwrite, { vue: false | VueLanguageOptions; }>; }>; export declare function resolveOptions({ generator, entry, cwd, dtsOnly, tsconfig, tsconfigRaw: overriddenTsconfigRaw, compilerOptions, sourcemap, resolver, cjsDefault, sideEffects, logger, customLanguages, typecheck, tsc, emitJs, oxc, tsgo, tsrs, ...deprecated }: Options): OptionsResolved; export declare function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }: Pick): Plugin; export declare function createGeneratePlugin(options: Pick): Plugin; export declare function dts(options?: Options): Plugin[]; export type { CustomLanguage, Generator, GeneratorResult, Logger, Options, TscOptions };