From 6d751189f1fbf0ef400a2b07743b6defb81fb4a1 Mon Sep 17 00:00:00 2001 From: Konstantin Yegupov Date: Tue, 23 Jul 2019 10:16:40 +0200 Subject: [PATCH] fix: expose all three inspect() overloads in plugin types (#83) --- lib/index.ts | 20 +++++++++++--------- package.json | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index b469796..af3c85f 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -60,23 +60,25 @@ export interface GradleInspectOptions { type Options = InspectOptions & GradleInspectOptions; -// TODO: move everything to inspect.ts, and make index.ts just a re-export of `inspect` with a typecheck +// Overload type definitions, so that when you call inspect() with an `options` literal (e.g. in tests), +// you will get a result of a specific corresponding type. export async function inspect( root: string, targetFile: string, - options?: SingleSubprojectInspectOptions & GradleInspectOptions): - Promise; + options?: SingleSubprojectInspectOptions & GradleInspectOptions, +): Promise; export async function inspect( root: string, targetFile: string, - options: MultiSubprojectInspectOptions & GradleInspectOptions): - Promise; + options: MultiSubprojectInspectOptions & GradleInspectOptions, +): Promise; +// General implementation. The result type depends on the runtime type of `options`. export async function inspect( - root: string, - targetFile: string, - options?: Options, - ): Promise { + root: string, + targetFile: string, + options?: Options, +): Promise { if (!options) { options = {dev: false}; } diff --git a/package.json b/package.json index a9db2be..c6cd4c2 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "author": "snyk.io", "license": "Apache-2.0", "devDependencies": { - "@snyk/cli-interface": "^1.2.0", + "@snyk/cli-interface": "^1.3.1", "@types/chalk": "^2.2.0", "@types/jest": "^24.0.13", "@types/node": "^4.9.1",