Type Alias GenerateConfig

    Data used to generate the bundled TS declaration.

    type GenerateConfig = {
        bundlePackageExports?: boolean;
        checkDefaultPath?: boolean;
        compilerOptions?: TsConfigJson.CompilerOptions;
        conditionImports?: resolve_exports.Options;
        dtsReplace?: Record<string, string>;
        emitCTS?: boolean;
        filterTags?: string | Iterable<string> | false | null;
        importsExternal?: boolean | ImportsPluginOptions;
        importsLocal?: boolean | ImportsPluginOptions;
        importsResolve?: boolean | ImportsResolvePluginOptions;
        input: string;
        logLevel?: LogLevel;
        output?: string;
        outputExt?: string;
        outputGraph?: string;
        outputGraphIndentation?: number;
        outputPostprocess?: string;
        plugins?: Iterable<string>;
        postprocess?: Iterable<ProcessorFunction>;
        prependFiles?: Iterable<string>;
        prependString?: Iterable<string>;
        prettier?: boolean | prettier.Options;
        removePrivateStatic?: boolean;
        rollupExternal?:
            | (string | RegExp)[]
            | RegExp
            | string
            | ((id: string, parentId: string, isResolved: boolean) => boolean);
        rollupOnwarn?: (
            warning: rollup.RollupLog,
            defaultHandler: (warning: string | rollup.RollupLog) => void,
        ) => void;
        rollupPaths?: Record<string, string> | ((id: string) => string);
        tsCheckJs?: boolean;
        tsconfig?: string;
        tsDiagnosticExternal?: boolean;
        tsDiagnosticFilter?: (
            params: { diagnostic: Diagnostic; message?: string },
        ) => boolean;
        tsDiagnosticLog?: boolean;
        tsFileWalk?: boolean;
        tsTransformers?: Iterable<
            TransformerFactory<Bundle | SourceFile>
            | CustomTransformerFactory,
        >;
    }
    Index

    Properties

    bundlePackageExports?: boolean

    When true attempt to bundle types of top level exported packages. This is useful for re-bundling libraries.

    checkDefaultPath?: boolean

    When true and bundling top level package exports via bundlePackageExports check for index.d.ts in the package root; this is off by default as usually this is indicative of and older package not updated for exports in package.json.

    compilerOptions?: TsConfigJson.CompilerOptions

    Typescript compiler options. https://www.typescriptlang.org/tsconfig

    conditionImports?: resolve_exports.Options

    resolve.exports conditional options for package.json imports field type.

    dtsReplace?: Record<string, string>

    Options for naive text replacement operating on the final bundled TS declaration file. The keys are converted into RegExp instances so may be a valid pattern to match.

    emitCTS?: boolean

    Output additional '.d.cts' file for strict Typescript adherence for packages that are dual ESM / CJS.

    filterTags?: string | Iterable<string> | false | null

    By default, jsdocRemoveNodeByTags('internal') transformer is automatically added removing all AST nodes that have the @internal tag. To generate declarations with internal tags set to false / null / undefined.

    importsExternal?: boolean | ImportsPluginOptions

    When defined enables importsExternal from the @typhonjs-build-test/rollup-plugin-pkg-imports package.

    importsLocal?: boolean | ImportsPluginOptions

    When defined enables importsLocal from the @typhonjs-build-test/rollup-plugin-pkg-imports package.

    importsResolve?: boolean | ImportsResolvePluginOptions

    When defined enables importsResolve from the @typhonjs-build-test/rollup-plugin-pkg-imports package.

    input: string

    The input entry source file path.

    logLevel?: LogLevel

    Defines the logging level; default: info.

    output?: string

    The output file path for the bundled TS declarations.

    outputExt?: string

    The bundled output TS declaration file extension. Normally a complete output path is provided when using generateDTS, but this can be useful when using the Rollup plugin to change the extension as desired.

    outputGraph?: string

    Outputs the package dependency graph to the given file path. The graph JSON is suitable for use in various graph libraries like cytoscape / Svelte Flow / amongst others.

    outputGraphIndentation?: number

    When outputting the dependency graph use this indentation value for the JSON output.

    outputPostprocess?: string

    When postprocessing is configured this is a helpful debugging mechanism to output the postprocessed declarations to a separate file making it easier to compare the results of any additional processing. You must specify a valid file path.

    plugins?: Iterable<string>

    An iterable list of NPM package names or local source files providing ESM plugins to load for additional file type support. Official 1st party plugins installed will automatically load. Use plugins to load any 3rd party plugins.

    An iterable list of postprocessing functions. Note: This is experimental!

    prependFiles?: Iterable<string>

    Directly prepend these files to the bundled output. The files are first attempted to be resolved relative to the entry point folder allowing a common configuration to be applied across multiple subpath exports. Then a second attempt is made with the path provided.

    prependString?: Iterable<string>

    Directly prepend these strings to the bundled output.

    prettier?: boolean | prettier.Options

    When defined as "false" prettier is not executed on the bundled declaration output. Otherwise, you may provide a custom prettier configuration object.

    removePrivateStatic?: boolean

    When processing ESM and this option is true a custom transformer is added to remove the renaming of private static class members that Typescript currently renames and improperly passes through to bundled declarations. Default: true.

    rollupExternal?:
        | (string | RegExp)[]
        | RegExp
        | string
        | ((id: string, parentId: string, isResolved: boolean) => boolean)
    rollupOnwarn?: (
        warning: rollup.RollupLog,
        defaultHandler: (warning: string | rollup.RollupLog) => void,
    ) => void

    Type Declaration

      • (
            warning: rollup.RollupLog,
            defaultHandler: (warning: string | rollup.RollupLog) => void,
        ): void
      • Parameters

        • warning: rollup.RollupLog

          RollupLog warning.

        • defaultHandler: (warning: string | rollup.RollupLog) => void

          Default Rollup warning handler.

        Returns void

    rollupPaths?: Record<string, string> | ((id: string) => string)
    tsCheckJs?: boolean

    When true set checkJs to default compiler options. This is a convenience parameter to quickly turn checkJs on / off. Default: false.

    tsconfig?: string

    Provide a file path to a tsconfig.json for custom compilerOptions configuration.

    tsDiagnosticExternal?: boolean

    By default, all diagnostic errors that are external to the common root path from the input source file will be filtered from diagnostic logging. Set to true to include all diagnostic errors in logging. If you set an explicit diagnostic filter function via the tsDiagnosticFilter this option is ignored.

    tsDiagnosticFilter?: (
        params: { diagnostic: Diagnostic; message?: string },
    ) => boolean

    Optional filter function to handle diagnostic messages in a similar manner as the onwarn Rollup callback. Return true to filter the given diagnostic from posting to console.error otherwise return false to include.

    Type Declaration

      • (params: { diagnostic: Diagnostic; message?: string }): boolean
      • Parameters

        • params: { diagnostic: Diagnostic; message?: string }

          The TS Diagnostic to filter and associated message.

        Returns boolean

    tsDiagnosticLog?: boolean

    When generating a DTS bundle you may opt to turn off any emitted TS compiler diagnostic messages; Default: true.

    tsFileWalk?: boolean

    When processing an ESM entry point and set to true all TS files located at the input path and all subdirectories are included as synthetic exports in the generated declarations. Setting to false only includes TS files in the direct input path.

    tsTransformers?: Iterable<
        TransformerFactory<Bundle | SourceFile>
        | CustomTransformerFactory,
    >

    A list of TransformerFactory or CustomTransformerFactory functions to process generated declaration AST while emitting intermediate types for bundling. https://github.com/itsdouges/typescript-transformer-handbook