From 89936814068d5e69a5f78b86ea0949f1bea8695f Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Wed, 26 Dec 2018 00:29:18 +0100 Subject: [PATCH] [list-git-remotes] Add types --- types/list-git-remotes/index.d.ts | 24 +++++++++++++++++++ .../list-git-remotes-tests.ts | 17 +++++++++++++ types/list-git-remotes/tsconfig.json | 23 ++++++++++++++++++ types/list-git-remotes/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 types/list-git-remotes/index.d.ts create mode 100644 types/list-git-remotes/list-git-remotes-tests.ts create mode 100644 types/list-git-remotes/tsconfig.json create mode 100644 types/list-git-remotes/tslint.json diff --git a/types/list-git-remotes/index.d.ts b/types/list-git-remotes/index.d.ts new file mode 100644 index 0000000000..f544110753 --- /dev/null +++ b/types/list-git-remotes/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for list-git-remotes 1.0 +// Project: https://github.com/jonschlinkert/list-git-remotes +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { ExecException, ExecSyncOptions } from 'child_process'; + +export = listGitRemotes; + +declare function listGitRemotes(callback: listGitRemotes.Callback): void; +declare function listGitRemotes(cwd: string, callback: listGitRemotes.Callback): void; + +declare namespace listGitRemotes { + function sync(cwd?: string, options?: ExecSyncOptions): Remotes; + function sync(options: ExecSyncOptions): Remotes; + + type Callback = (err: ExecException | null, remotes: Remotes, stderr?: string) => void; + + interface Remotes { + [key: string]: string; + } +} diff --git a/types/list-git-remotes/list-git-remotes-tests.ts b/types/list-git-remotes/list-git-remotes-tests.ts new file mode 100644 index 0000000000..8114790ce6 --- /dev/null +++ b/types/list-git-remotes/list-git-remotes-tests.ts @@ -0,0 +1,17 @@ +import remotes = require('list-git-remotes'); + +remotes((err, res, stderr) => { + err; // $ExpectType ExecException | null + res; // $ExpectType Remotes + stderr; // $ExpectType string | undefined +}); +remotes('some/project', (err, res, stderr) => { + err; // $ExpectType ExecException | null + res; // $ExpectType Remotes + stderr; // $ExpectType string | undefined +}); + +remotes.sync(); // $ExpectType Remotes +remotes.sync('some/project'); // $ExpectType Remotes +remotes.sync('some/project', { shell: 'foo' }); // $ExpectType Remotes +remotes.sync({ cwd: 'some/project', shell: 'foo' }); // $ExpectType Remotes diff --git a/types/list-git-remotes/tsconfig.json b/types/list-git-remotes/tsconfig.json new file mode 100644 index 0000000000..28e46b572b --- /dev/null +++ b/types/list-git-remotes/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", + "list-git-remotes-tests.ts" + ] +} diff --git a/types/list-git-remotes/tslint.json b/types/list-git-remotes/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/list-git-remotes/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }