DefinitelyTyped/types/which/which-tests.ts
Andrew Bradley eba05bf2ac Updates declarations for "which"
- Enables strictNullChecks
- Adds options: `nothrow`, `all`, `path`, and `pathExt`
- Uses function overloading to pick most specific return types based on `all` and `nothrow` options
2017-12-21 15:43:11 -05:00

36 lines
731 B
TypeScript

import which = require("which");
which("cat", (err, path) => {
console.log(path);
});
var path = which.sync("cat");
console.log(path);
which("cat", {all: true}, (err, paths) => {
if(err) return;
if(paths) {
for(let path of paths) {
console.log(path);
}
}
});
var paths = which.sync("cat", {all: true});
for(let path of paths) {
console.log(path);
}
var paths2 = which.sync("cat", {all: true, nothrow: true});
if(paths2 !== null) {
for(let path of paths2) {
console.log(path);
}
}
var path2 = which.sync("cat", {path: 'replacement path', pathExt: 'replacement pathext'});
which("cat", {path: 'replacement path', pathExt: 'replacement pathext'}, (err, path) => {
const a: string = path!;
});