跳到主要内容
FarmFarm
Version: 1.x
本页目录

@farmfe/js-plugin-dts

支持 .d.ts 文件。 该插件用于构建的工具库,为您的 ts 代码生成“.d.ts”

Installation

javascript
npm install @farmfe/js-plugin-dts
javascript
yarn add @farmfe/js-plugin-dts
javascript
pnpm add @farmfe/js-plugin-dts

Usage

ts
import { UserConfig } from '@farmfe/core';
import farmJsPluginDts from '@farmfe/js-plugin-dts';

const config: UserConfig = {
  plugins: [
    farmJsPluginDts({ /* options */ })
  ]
}

Options

ts
import type { ts, Diagnostic } from 'ts-morph';

export interface DtsPluginOptions {
  /**
   * Depends on the root directory
   */
  root?: string;

  /**
   * Declaration files output directory
   */
  outputDir?: string | string[];

  /**
   * set the root path of the entry files
   */
  entryRoot?: string;

  /**
   * Project init compilerOptions using by ts-morph
   */
  compilerOptions?: ts.CompilerOptions | null;

  /**
   * Project init tsconfig.json file path by ts-morph
   */
  tsConfigPath?: string;

  /**
   * set include glob
   */
  include?: string | string[];

  /**
   * set exclude glob
   */
  exclude?: string | string[];

  /**
   * Whether copy .d.ts source files into outputDir
   *
   * @default false
   */
  copyDtsFiles?: boolean;

  /**
   * Whether emit nothing when has any diagnostic
   *
   * @default false
   */
  noEmitOnError?: boolean;

  /**
   * Whether skip typescript diagnostics
   *
   * @default true
   */
  skipDiagnostics?: boolean;

  /**
   * Customize typescript lib folder path
   *
   * @default undefined
   */
  libFolderPath?: string;

  /**
   * According to the length to judge whether there is any type error
   */
  afterDiagnostic?: (diagnostics: Diagnostic[]) => void | Promise<void>;
}

100%

Drag or pinch to explore. Keyboard: + / − zoom, arrows pan, 0 resets, Esc closes.