Added type definitions for hidefile (#46712)

* Added type definitions for hidefile

* hidefile: Fix incorrect typings definition structure

* hidefile: Fix incorrect DT header
This commit is contained in:
Nicholas Nelson 2020-08-20 22:11:19 -07:00 committed by GitHub
parent 416202f3af
commit fd8aaff6bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 0 deletions

48
types/hidefile/index.d.ts vendored Normal file
View File

@ -0,0 +1,48 @@
// Type definitions for hidefile 3.0
// Project: https://github.com/stevenvachon/hidefile
// Definitions by: Nicholas Nelson <https://github.com/nelsonni>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
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;

View File

@ -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

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }