mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
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:
parent
30b8267129
commit
ad85bebc6e
@ -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();
|
||||
|
||||
5
types/glob/index.d.ts
vendored
5
types/glob/index.d.ts
vendored
@ -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[]>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user