diff --git a/types/trash/index.d.ts b/types/trash/index.d.ts index 2da4838695..07852a80fd 100644 --- a/types/trash/index.d.ts +++ b/types/trash/index.d.ts @@ -2,12 +2,21 @@ // Project: https://github.com/sindresorhus/trash#readme // Definitions by: Matthew James // Keiichiro Amemiya +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface TrashOptions { - glob: boolean; +/** + * Move files and folders to the trash + * + * @param paths Accepts paths and [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). + * @param options.glob Enable globbing when matching file paths + */ +declare function trash(paths: string | string[], options?: trash.Options): Promise; + +declare namespace trash { + interface Options { + glob: boolean; + } } -declare function trash(iterable: Iterable, opts?: TrashOptions): Promise; - export = trash; diff --git a/types/trash/trash-tests.ts b/types/trash/trash-tests.ts index d3722539ce..fb040e2c8f 100644 --- a/types/trash/trash-tests.ts +++ b/types/trash/trash-tests.ts @@ -1,15 +1,20 @@ -import trash = require("trash"); +import trash = require('trash'); -async function testTrashNoArgs() { - await trash(["/path/to/item1", "/path/to/item2"]); +async function testTrashNoArgsSinglePath() { + await trash('/path/to/item1'); +} + +async function testTrashNoArgsMultiPath() { + await trash(['/path/to/item1', '/path/to/item2']); } async function testTrashWithArgs() { - await trash(["/path/to/item1", "/path/to/item2"], { glob: false }); + const options: trash.Options = { glob: false }; + await trash(['/path/to/item1', '/path/to/item2'], options); } -async function testTrashPerDocumentation() { - trash(["*.png", "!rainbow.png"]).then(() => { - console.log("done"); - }); +function testTrashPerDocumentation() { + (async () => { + await trash(['*.png', '!rainbow.png']); + })(); } diff --git a/types/trash/tsconfig.json b/types/trash/tsconfig.json index 98e9a458d1..c60478e474 100644 --- a/types/trash/tsconfig.json +++ b/types/trash/tsconfig.json @@ -2,8 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "target": "es2015", "noImplicitAny": true, @@ -22,4 +21,4 @@ "index.d.ts", "trash-tests.ts" ] -} \ No newline at end of file +}