fix(glob): correct return type to mach Glob interface (#45193)

This changes detail of lesser known usage of the module.
As pointed in #45192 the function usage should return fully initialized
instance of the glob:
https://git.io/Jf6WM

/cc @Shinigami92

Thanks!

Fixes #45192
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-06-05 01:32:41 +02:00 committed by GitHub
parent 30b8267129
commit ad85bebc6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -32,3 +32,15 @@ const Glob = glob.Glob;
declare const ignore: ReadonlyArray<string>;
glob.sync('/foo/*', {realpath: true, realpathCache: {'/foo/bar': '/bar'}, ignore: '/foo/baz'});
glob.sync('/*', {ignore, nodir: true, cache: {'/': ['bar', 'baz']}, statCache: {'/foo/bar': false, '/foo/baz': {isDirectory() { return true; }}}});
// $ExpectType IGlob
const globInstance = glob('**/*.js', { mark: true }, (er, matches) => {
if (er) {
return;
}
er; // $ExpectType null
matches; // $ExpectType string[]
});
globInstance.pause();
globInstance.resume();
globInstance.abort();

View File

@ -3,6 +3,7 @@
// Definitions by: vvakame <https://github.com/vvakame>
// voy <https://github.com/voy>
// Klaus Meinhardt <https://github.com/ajafff>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@ -10,8 +11,8 @@
import events = require("events");
import minimatch = require("minimatch");
declare function G(pattern: string, cb: (err: Error | null, matches: string[]) => void): void;
declare function G(pattern: string, options: G.IOptions, cb: (err: Error | null, matches: string[]) => void): void;
declare function G(pattern: string, cb: (err: Error | null, matches: string[]) => void): G.IGlob;
declare function G(pattern: string, options: G.IOptions, cb: (err: Error | null, matches: string[]) => void): G.IGlob;
declare namespace G {
function __promisify__(pattern: string, options?: IOptions): Promise<string[]>;