Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: types #661

Merged
merged 1 commit into from Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -549,10 +549,10 @@ Type:
```ts
type transform =
| {
transformer: (input: string, absoluteFilename: string) => string;
transformer: (input: string, absoluteFilename: string) => string | Buffer;
cache?: boolean | TransformerCacheObject | undefined;
}
| ((input: string, absoluteFilename: string) => string);
| ((input: string, absoluteFilename: string) => string | Buffer);
```

Default: `undefined`
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Expand Up @@ -74,6 +74,7 @@ const template = /\[\\*([\w:]+)\\*\]/i;
* @callback TransformerFunction
* @param {Buffer} input
* @param {string} absoluteFilename
* @returns {string | Buffer}
*/

/**
Expand Down
6 changes: 5 additions & 1 deletion types/index.d.ts
Expand Up @@ -49,6 +49,7 @@ export = CopyPlugin;
* @callback TransformerFunction
* @param {Buffer} input
* @param {string} absoluteFilename
* @returns {string | Buffer}
*/
/**
* @typedef {{ keys: { [key: string]: any } } | { keys: ((defaultCacheKeys: { [key: string]: any }, absoluteFilename: string) => Promise<{ [key: string]: any }>) }} TransformerCacheObject
Expand Down Expand Up @@ -229,7 +230,10 @@ type ToFunction = (pathData: {
}) => string;
type To = string | ToFunction;
type ToType = "dir" | "file" | "template";
type TransformerFunction = (input: Buffer, absoluteFilename: string) => any;
type TransformerFunction = (
input: Buffer,
absoluteFilename: string
) => string | Buffer;
type TransformerCacheObject =
| {
keys: {
Expand Down