mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Add overload that returns promise (#38864)
* Add overload that returns promise which@2.0.1 supports `Promise` * Add test for the promise variant * Add promise overloads with options * Update which-tests.ts * Add missing ';'
This commit is contained in:
Vendored
+4
@@ -13,6 +13,10 @@ declare function which(cmd: string, options: which.AsyncOptions & which.OptionsF
|
||||
declare function which(cmd: string, options: which.AsyncOptions, cb: (err: Error | null, path: string | Array<string> | undefined) => void): void;
|
||||
/** Finds the first instance of a specified executable in the PATH environment variable */
|
||||
declare function which(cmd: string, cb: (err: Error | null, path: string | undefined) => void): void;
|
||||
/** Finds the first instance of a specified executable in the PATH environment variable */
|
||||
declare function which(cmd: string, options: which.AsyncOptions & which.OptionsAll): Promise<string[]>;
|
||||
/** Finds the first instance of a specified executable in the PATH environment variable */
|
||||
declare function which(cmd: string, options?: which.AsyncOptions & which.OptionsFirst): Promise<string>;
|
||||
declare namespace which {
|
||||
/** Finds all instances of a specified executable in the PATH environment variable */
|
||||
function sync(cmd: string, options: which.Options & which.OptionsAll & which.OptionsNoThrow): Array<string> | null;
|
||||
|
||||
@@ -17,6 +17,10 @@ which("cat", {all: true}, (err, paths) => {
|
||||
}
|
||||
});
|
||||
|
||||
var promise: Promise<string> = which("cat");
|
||||
var promise1: Promise<string> = which("cat", { all: false });
|
||||
var promise2: Promise<string[]> = which("cat", { all: true });
|
||||
|
||||
var paths = which.sync("cat", {all: true});
|
||||
for(let path of paths) {
|
||||
console.log(path);
|
||||
|
||||
Reference in New Issue
Block a user