[isexe] Add types

This commit is contained in:
Dimitri Benin 2018-12-23 23:30:02 +01:00
parent a1b863c972
commit d819aa2aa8
4 changed files with 72 additions and 0 deletions

30
types/isexe/index.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
// Type definitions for isexe 2.0
// Project: https://github.com/isaacs/isexe#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export = isExe;
declare function isExe(path: string, options?: isExe.Options): Promise<boolean>;
declare function isExe(
path: string,
callback: (error: NodeJS.ErrnoException | undefined, isExe: boolean) => void
): void;
declare function isExe(
path: string,
options: isExe.Options,
callback: (error: NodeJS.ErrnoException | undefined, isExe: boolean) => void
): void;
declare namespace isExe {
function sync(path: string, options?: Options): boolean;
interface Options {
ignoreErrors?: boolean;
uid?: number;
gid?: number;
pathExt?: string;
}
}

View File

@ -0,0 +1,18 @@
import isexe = require('isexe');
isexe('some-file-name'); // $ExpectType Promise<boolean>
isexe('some-file-name', { ignoreErrors: true }); // $ExpectType Promise<boolean>
isexe('some-file-name', { uid: 123 }); // $ExpectType Promise<boolean>
isexe('some-file-name', { gid: 123 }); // $ExpectType Promise<boolean>
isexe('some-file-name', { pathExt: 'exe;bat' }); // $ExpectType Promise<boolean>
isexe('some-file-name', (err, isExe) => {
err; // $ExpectType ErrnoException | undefined
isExe; // $ExpectType boolean
});
isexe('some-file-name', { ignoreErrors: true }, (err, isExe) => {
err; // $ExpectType ErrnoException | undefined
isExe; // $ExpectType boolean
});
isexe.sync('some-file-name'); // $ExpectType boolean
isexe.sync('some-file-name', { ignoreErrors: true }); // $ExpectType boolean

23
types/isexe/tsconfig.json Normal file
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",
"isexe-tests.ts"
]
}

1
types/isexe/tslint.json Normal file
View File

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