From fd8aaff6bbdd9b739fc599ad71d75568f4bba2db Mon Sep 17 00:00:00 2001 From: Nicholas Nelson Date: Thu, 20 Aug 2020 22:11:19 -0700 Subject: [PATCH] Added type definitions for hidefile (#46712) * Added type definitions for hidefile * hidefile: Fix incorrect typings definition structure * hidefile: Fix incorrect DT header --- types/hidefile/index.d.ts | 48 +++++++++++++++++++++++ types/hidefile/test/hidefile-tests.cjs.ts | 11 ++++++ types/hidefile/tsconfig.json | 23 +++++++++++ types/hidefile/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 types/hidefile/index.d.ts create mode 100644 types/hidefile/test/hidefile-tests.cjs.ts create mode 100644 types/hidefile/tsconfig.json create mode 100644 types/hidefile/tslint.json diff --git a/types/hidefile/index.d.ts b/types/hidefile/index.d.ts new file mode 100644 index 0000000000..2eba5689d1 --- /dev/null +++ b/types/hidefile/index.d.ts @@ -0,0 +1,48 @@ +// Type definitions for hidefile 3.0 +// Project: https://github.com/stevenvachon/hidefile +// Definitions by: Nicholas Nelson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { URL } from 'url'; + +export function hide( + path: string | Buffer | URL, + callback: (error: Error | null, newpath?: string | Buffer | URL) => unknown +): void; + +export function hideSync( + path: string | Buffer | URL +): string | Buffer | URL; + +export function isDotPrefixed( + path: string | Buffer | URL +): boolean; + +export function isHidden( + path: string | Buffer | URL, + callback: (error: Error | null, result: boolean) => unknown +): void; + +export function isHiddenSync( + path: string | Buffer | URL +): boolean; + +export function reveal( + path: string | Buffer | URL, + callback: (error: Error | null, newpath?: string | Buffer | URL) => unknown +): void; + +export function revealSync( + path: string | Buffer | URL +): string | Buffer | URL; + +export function shouldBeHidden( + path: string | Buffer | URL, + callback: (error: Error | null, result: boolean) => unknown +): void; + +export function shouldBeHiddenSync( + path: string | Buffer | URL +): boolean; diff --git a/types/hidefile/test/hidefile-tests.cjs.ts b/types/hidefile/test/hidefile-tests.cjs.ts new file mode 100644 index 0000000000..374f896be4 --- /dev/null +++ b/types/hidefile/test/hidefile-tests.cjs.ts @@ -0,0 +1,11 @@ +import hidefile = require('hidefile'); + +hidefile.hide("./", () => {}); // $ExpectType void +hidefile.hideSync("./"); // $ExpectType string | Buffer | URL +hidefile.isDotPrefixed("./"); // $ExpectType boolean +hidefile.isHidden("./", () => {}); // $ExpectType void +hidefile.isHiddenSync("./"); // $ExpectType boolean +hidefile.reveal("./", () => {}); // $ExpectType void +hidefile.revealSync("./"); // $ExpectType string | Buffer | URL +hidefile.shouldBeHidden("./", () => {}); // $ExpectType void +hidefile.shouldBeHiddenSync("./"); // $ExpectType boolean diff --git a/types/hidefile/tsconfig.json b/types/hidefile/tsconfig.json new file mode 100644 index 0000000000..f8b80fa0c7 --- /dev/null +++ b/types/hidefile/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/hidefile-tests.cjs.ts" + ] +} diff --git a/types/hidefile/tslint.json b/types/hidefile/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hidefile/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }