Skip to content

Commit

Permalink
feat: add jsdoc to options type
Browse files Browse the repository at this point in the history
  • Loading branch information
herberttn committed Jul 3, 2023
1 parent 1471e64 commit 7699aa5
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,77 @@ import type { CompilerOptions } from 'typescript';
import type { FilterPattern, Plugin } from 'vite';

interface Options {
/**
* Apply the plugin only for serve or build, or on certain conditions.
*/
apply?: Plugin['apply'];

/**
* Enforce plugin invocation tier similar to webpack loaders.
*
* Plugin invocation order:
* - alias resolution
* - `enforce: 'pre'` plugins
* - vite core plugins
* - normal plugins
* - vite build plugins
* - `enforce: 'post'` plugins
* - vite build post plugins
*/
enforce?: Plugin['enforce'];

/**
* Filter when to transpile based on the file code or location.
* If not provided, all code and files will be transpiled.
*/
filter?: {
/**
* Determines which files should be transpiled based on their code.
* If not provided, allows any file code to be transpiled.
*
* @param code the raw code.
* @returns whether to transpile or not.
*/
code?: (code: string) => boolean;

/**
* Determines which files should be transpiled based on their location.
* If not provided, allows any file location be transpiled.
*/
files?: {
/**
* Files to transpile.
* If not provided, matches everything.
*
* Supports globbing.
*/
include?: FilterPattern;

/**
* Files to ignore.
* If not provided, doesn't ignore anything.
*
* Supports globbing.
*/
exclude?: FilterPattern;
};
};

/**
* TypeScript configuration.
*/
tsconfig?: {
/**
* The location of the tsconfig.json file.
* If not provided, the plugin will detect it automatically based on the file location.
*
* Must be absolute.
*/
location?: string;

/**
* Overrides the compiler options found in the tsconfig.json file.
*/
override?: CompilerOptions;
};
}
Expand Down

0 comments on commit 7699aa5

Please sign in to comment.