From efb26511dd0a39f35a1df375f3fb2d7a53df8785 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sun, 18 Nov 2018 19:24:22 +0000 Subject: [PATCH] add types for find-package-json (#30628) --- .../find-package-json-tests.ts | 19 ++++++ types/find-package-json/index.d.ts | 63 +++++++++++++++++++ types/find-package-json/tsconfig.json | 23 +++++++ types/find-package-json/tslint.json | 1 + 4 files changed, 106 insertions(+) create mode 100644 types/find-package-json/find-package-json-tests.ts create mode 100644 types/find-package-json/index.d.ts create mode 100644 types/find-package-json/tsconfig.json create mode 100644 types/find-package-json/tslint.json diff --git a/types/find-package-json/find-package-json-tests.ts b/types/find-package-json/find-package-json-tests.ts new file mode 100644 index 0000000000..bbdca6c6dd --- /dev/null +++ b/types/find-package-json/find-package-json-tests.ts @@ -0,0 +1,19 @@ +"use strict"; + +import finder = require("find-package-json"); + +const f = finder(); +const fDirname = finder(__dirname); +const fModule: finder.FinderIterator = finder(module); + +const findResult = f.next(); + +if (findResult.done) { + const res: finder.Done = findResult; + const value: undefined = findResult.value; + const filename: undefined = findResult.filename; +} else { + const res: finder.FoundPackage = findResult; + const value: finder.Package = findResult.value; + const filename: string = findResult.filename; +} diff --git a/types/find-package-json/index.d.ts b/types/find-package-json/index.d.ts new file mode 100644 index 0000000000..d0478ecbe4 --- /dev/null +++ b/types/find-package-json/index.d.ts @@ -0,0 +1,63 @@ +// Type definitions for find-package-json 1.1 +// Project: https://github.com/3rd-Eden/find-package-json#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = finder; + +import Module = NodeJS.Module; + +declare function finder(root?: string | Module): finder.FinderIterator; + +declare namespace finder { + interface FinderIterator { + next(): FindResult; + } + + type FindResult = FoundPackage | Done; + + interface FoundPackage { + done: false; + value: Package; + filename: string; + } + + interface Done { + done: true; + value: undefined; + filename: undefined; + } + + interface Person { + name?: string; + email?: string; + url?: string; + } + + interface Package { + [k: string]: any; + name?: string; + version?: string; + files?: string[]; + bin?: { [k: string]: string }; + man?: string[]; + keywords?: string[]; + author?: Person; + maintainers?: Person[]; + contributors?: Person[]; + bundleDependencies?: { [name: string]: string }; + dependencies?: { [name: string]: string }; + devDependencies?: { [name: string]: string }; + optionalDependencies?: { [name: string]: string }; + description?: string; + engines?: { [type: string]: string }; + license?: string; + repository?: { type: string; url: string }; + bugs?: { url: string; email?: string } | { url?: string; email: string }; + homepage?: string; + scripts?: { [k: string]: string }; + readme?: string; + } +} diff --git a/types/find-package-json/tsconfig.json b/types/find-package-json/tsconfig.json new file mode 100644 index 0000000000..4aa74e4219 --- /dev/null +++ b/types/find-package-json/tsconfig.json @@ -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", + "find-package-json-tests.ts" + ] +} diff --git a/types/find-package-json/tslint.json b/types/find-package-json/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/find-package-json/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }