From 57e1894ced57e2b2a6571df7a7eb2bbe6ebc145b Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Fri, 11 Aug 2017 01:38:54 +0200 Subject: [PATCH] [find-up] add typings (#18838) --- types/find-up/find-up-tests.ts | 14 ++++++++++++++ types/find-up/index.d.ts | 16 ++++++++++++++++ types/find-up/tsconfig.json | 22 ++++++++++++++++++++++ types/find-up/tslint.json | 1 + 4 files changed, 53 insertions(+) create mode 100644 types/find-up/find-up-tests.ts create mode 100644 types/find-up/index.d.ts create mode 100644 types/find-up/tsconfig.json create mode 100644 types/find-up/tslint.json diff --git a/types/find-up/find-up-tests.ts b/types/find-up/find-up-tests.ts new file mode 100644 index 0000000000..08b4c5d2ed --- /dev/null +++ b/types/find-up/find-up-tests.ts @@ -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: ''}); diff --git a/types/find-up/index.d.ts b/types/find-up/index.d.ts new file mode 100644 index 0000000000..d882992283 --- /dev/null +++ b/types/find-up/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for find-up 2.1 +// Project: https://github.com/sindresorhus/find-up#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = findUp; + +declare function findUp(filename: string | string[], options?: findUp.Options): Promise; + +declare namespace findUp { + function sync(filename: string | string[], options?: findUp.Options): string | null; + + interface Options { + cwd?: string; + } +} diff --git a/types/find-up/tsconfig.json b/types/find-up/tsconfig.json new file mode 100644 index 0000000000..104004639a --- /dev/null +++ b/types/find-up/tsconfig.json @@ -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" + ] +} diff --git a/types/find-up/tslint.json b/types/find-up/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/find-up/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }