[find-up] add typings (#18838)

This commit is contained in:
Dimitri Benin
2017-08-11 01:38:54 +02:00
committed by Mohamed Hegazy
parent 46888997b8
commit 57e1894ced
4 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import findUp = require('find-up');
findUp('unicorn.png').then(filepath => {
filepath; // $ExpectType string | null
});
findUp('unicorn.png', {cwd: ''});
findUp(['rainbow.png', 'unicorn.png']);
findUp(['rainbow.png', 'unicorn.png'], {cwd: ''});
findUp.sync('unicorn.png'); // $ExpectType string | null
findUp.sync('unicorn.png', {cwd: ''});
findUp.sync(['rainbow.png', 'unicorn.png']);
findUp.sync(['rainbow.png', 'unicorn.png'], {cwd: ''});

16
types/find-up/index.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
// Type definitions for find-up 2.1
// Project: https://github.com/sindresorhus/find-up#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = findUp;
declare function findUp(filename: string | string[], options?: findUp.Options): Promise<string | null>;
declare namespace findUp {
function sync(filename: string | string[], options?: findUp.Options): string | null;
interface Options {
cwd?: string;
}
}

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"find-up-tests.ts"
]
}

View File

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