diff --git a/types/rmfr/index.d.ts b/types/rmfr/index.d.ts new file mode 100644 index 0000000000..fc7c608e81 --- /dev/null +++ b/types/rmfr/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for rmfr 2.0 +// Project: https://github.com/shinnn/rmfr#readme +// Definitions by: Alan Plum +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import rimraf = require("rimraf"); + +declare namespace rmfr { + type Options = rimraf.Options & { + glob?: rimraf.Options["glob"] | true; + disableGlob?: never; + }; +} +declare function rmfr(path: string, options?: rmfr.Options): Promise; + +export = rmfr; diff --git a/types/rmfr/rmfr-tests.ts b/types/rmfr/rmfr-tests.ts new file mode 100644 index 0000000000..efec2dd480 --- /dev/null +++ b/types/rmfr/rmfr-tests.ts @@ -0,0 +1,39 @@ +import rmfr = require("rmfr"); + +(async () => { + // happy + await rmfr("tmp_file"); + await rmfr("tmp_d*", {}); + await rmfr("../{tmp_d*,test.js}", { + glob: { + cwd: "node_modules", + ignore: "some_filename" + } + }); + await rmfr("test.js", { + glob: { + cwd: "this/directory/does/not/exist" + } + }); + + // $ExpectError + await rmfr(".gitignore", { unlink: (path, cb) => cb(new Error()) }); + // $ExpectError + await rmfr(); + // $ExpectError + await rmfr("<", { o: "O" }, "/"); + // $ExpectError + await rmfr(["1"], { glob: true }); + // $ExpectError + await rmfr("foo", 1); + // $ExpectError + await rmfr("foo", { chmod: new Set(["a"]) }); + // $ExpectError + await rmfr("foo", { + maxBusyTries: "foo", + emfileWait: "bar", + glob: "baz" + }); + // $ExpectError + await rmfr("foo", { disableGlob: true }); +})(); diff --git a/types/rmfr/tsconfig.json b/types/rmfr/tsconfig.json new file mode 100644 index 0000000000..cbe39dd006 --- /dev/null +++ b/types/rmfr/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "rmfr-tests.ts"] +} diff --git a/types/rmfr/tslint.json b/types/rmfr/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/rmfr/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }