Skip to content

Commit

Permalink
add types for webpack-files-archive-plugin (DefinitelyTyped#60220)
Browse files Browse the repository at this point in the history
* add types for webpack-files-archive-plugin

* fix reference and test

* fix webpack version

* add webpack to tsconfig path

* add tapable

* re fix webpack version
  • Loading branch information
yusufades authored May 6, 2022
1 parent c34686c commit dd8cbcb
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
34 changes: 34 additions & 0 deletions types/webpack-files-archive-plugin/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Type definitions for webpack-files-archive-plugin 1.0
// Project: https://github.com/himanshuapril1/webpack-files-archive-plugin
// Definitions by: Yusuf Ades <https://github.com/yusufades>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />
import type { Compiler } from 'webpack';

declare namespace WebpackFilesArchivePlugin {
type Formats = 'tar' | 'zip';

interface Options {
/**
* Archive formats to use, can be 'tar' or 'zip'
*/
format: Formats | Formats[];
/**
* Directory location of files to be archived.
*/
output?: string;
/**
* A different extension to use instead of tar.gz or zip (without leading .)
*/
ext?: string;
}
}

declare class WebpackFilesArchivePlugin {
constructor(options: WebpackFilesArchivePlugin.Options);

apply(compiler: Compiler): void;
}

export = WebpackFilesArchivePlugin;
7 changes: 7 additions & 0 deletions types/webpack-files-archive-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": true,
"dependencies": {
"tapable": "^2.2.0",
"webpack": "5.0.0"
}
}
31 changes: 31 additions & 0 deletions types/webpack-files-archive-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"tapable": [
"./node_modules/tapable"
],
"webpack": [
"./node_modules/webpack"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webpack-files-archive-plugin-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/webpack-files-archive-plugin/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import FilesArchivePlugin = require('webpack-files-archive-plugin');
import { Configuration } from 'webpack';

const config: Configuration = {
plugins: [
// $ExpectError
new FilesArchivePlugin(),
new FilesArchivePlugin({
format: ['zip', 'tar'],
}),
new FilesArchivePlugin({
format: 'zip',
}),
new FilesArchivePlugin({
format: 'tar',
}),
new FilesArchivePlugin({
format: 'rar', // $ExpectError
}),
new FilesArchivePlugin({
format: ['zip', 'tar'],
output: 'build',
ext: 'gz',
}),
],
};

0 comments on commit dd8cbcb

Please sign in to comment.