Add types for pkg-dir package (#22601)

This commit is contained in:
Steph-W
2018-01-02 19:45:33 +01:00
committed by Mohamed Hegazy
parent 3aa8aa9e93
commit 60eb4d9ea2
4 changed files with 47 additions and 0 deletions

12
types/pkg-dir/index.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
// Type definitions for pkg-dir 2.0
// Project: https://github.com/sindresorhus/pkg-dir#readme
// Definitions by: NK-WEB-Git <https://github.com/NK-WEB-Git>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = pkgDir;
declare function pkgDir(cwd?: string): Promise<string | null>;
declare namespace pkgDir {
function sync(cwd?: string): string | null;
}

View File

@@ -0,0 +1,11 @@
import pkgDir = require('pkg-dir');
pkgDir('/Users/project/pkg-dir').then(rootDir => {
rootDir; // $ExpectType string | null
});
pkgDir().then(rootDir => {
rootDir;
});
pkgDir.sync('/Users/project/pkg-dir'); // $ExpectType string | null

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",
"pkg-dir-tests.ts"
]
}

View File

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