From 9b5743fcf341fb675ddd8eec257a813a513cbdac Mon Sep 17 00:00:00 2001 From: Glen Date: Sun, 10 Jan 2016 14:50:03 +0200 Subject: [PATCH] Move namespaces to inside the module declarations --- micromatch/micromatch.d.ts | 209 +++++++++++++++++---------------- parse-glob/parse-glob-tests.ts | 2 +- parse-glob/parse-glob.d.ts | 160 ++++++++++++------------- 3 files changed, 187 insertions(+), 184 deletions(-) diff --git a/micromatch/micromatch.d.ts b/micromatch/micromatch.d.ts index db3897fa2..e84b6c339 100644 --- a/micromatch/micromatch.d.ts +++ b/micromatch/micromatch.d.ts @@ -5,158 +5,161 @@ /// -declare namespace Micromatch { - type Pattern = (string | RegExp | ((filePath: string) => boolean)); -} - declare module 'micromatch' { - interface MicromatchOptions { - /** - * Normalize slashes in file paths and glob patterns to forward slashes. - */ - unixify?: boolean; - /** - * Match dotfiles. Same behavior as minimatch. - */ - dot?: boolean; - /** - * Unescape slashes in glob patterns. Use cautiously, especially on windows. - */ - unescape?: boolean; - /** - * Remove duplicate elements from the result array. - */ - nodupes?: boolean; - /** - * Allow glob patterns without slashes to match a file path based on its basename. Same behavior as minimatch. - */ - matchBase?: boolean; - /** - * Don't expand braces in glob patterns. Same behavior as minimatch nobrace. - */ - nobraces?: boolean; - /** - * Don't expand POSIX bracket expressions. - */ - nobrackets?: boolean; - /** - * Don't expand extended globs. - */ - noextglob?: boolean; - /** - * Use a case-insensitive regex for matching files. Same behavior as minimatch. - */ - nocase?: boolean; - /** - * If true, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty - * array. Same behavior as minimatch. - */ - nonull?: boolean; - /** - * Cache the platform (e.g. win32) to prevent this from being looked up for every file path. - */ - cache?: boolean; - } + import parseGlob = require('parse-glob'); - interface Glob { - options: {}; // TODO: Expand? - pattern: string; - history: {msg: any, pattern: string}[]; - tokens: ParseGlob.Result; - orig: string; - negated: boolean; + namespace micromatch { + type Pattern = (string | RegExp | ((filePath: string) => boolean)); - /** - * Initialize defaults. - */ - init(pattern: string): void; + interface Options { + /** + * Normalize slashes in file paths and glob patterns to forward slashes. + */ + unixify?: boolean; + /** + * Match dotfiles. Same behavior as minimatch. + */ + dot?: boolean; + /** + * Unescape slashes in glob patterns. Use cautiously, especially on windows. + */ + unescape?: boolean; + /** + * Remove duplicate elements from the result array. + */ + nodupes?: boolean; + /** + * Allow glob patterns without slashes to match a file path based on its basename. Same behavior as + * minimatch. + */ + matchBase?: boolean; + /** + * Don't expand braces in glob patterns. Same behavior as minimatch nobrace. + */ + nobraces?: boolean; + /** + * Don't expand POSIX bracket expressions. + */ + nobrackets?: boolean; + /** + * Don't expand extended globs. + */ + noextglob?: boolean; + /** + * Use a case-insensitive regex for matching files. Same behavior as minimatch. + */ + nocase?: boolean; + /** + * If true, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty + * array. Same behavior as minimatch. + */ + nonull?: boolean; + /** + * Cache the platform (e.g. win32) to prevent this from being looked up for every file path. + */ + cache?: boolean; + } - /** - * Push a change into `glob.history`. Useful for debugging. - */ - track(msg: any): void; + interface Glob { + options: {}; // TODO: Expand? + pattern: string; + history: {msg: any, pattern: string}[]; + tokens: parseGlob.Result; + orig: string; + negated: boolean; - /** - * Return true if `glob.pattern` was negated with `!`, also remove the `!` from the pattern. - */ - isNegated(): boolean; + /** + * Initialize defaults. + */ + init(pattern: string): void; - /** - * Expand braces in the given glob pattern. - */ - braces(): void; + /** + * Push a change into `glob.history`. Useful for debugging. + */ + track(msg: any): void; - /** - * Expand bracket expressions in `glob.pattern`. - */ - brackets(): void; + /** + * Return true if `glob.pattern` was negated with `!`, also remove the `!` from the pattern. + */ + isNegated(): boolean; - /** - * Expand extended globs in `glob.pattern`. - */ - extglob(): void; + /** + * Expand braces in the given glob pattern. + */ + braces(): void; - /** - * Parse the given pattern. - */ - parse(pattern: string): ParseGlob.Result; + /** + * Expand bracket expressions in `glob.pattern`. + */ + brackets(): void; - /** - * Escape special characters in the given string. - */ - escape(pattern: string): string; + /** + * Expand extended globs in `glob.pattern`. + */ + extglob(): void; - /** - * Unescape special characters in the given string. - */ - unescape(pattern: string): string; + /** + * Parse the given pattern. + */ + parse(pattern: string): parseGlob.Result; + + /** + * Escape special characters in the given string. + */ + escape(pattern: string): string; + + /** + * Unescape special characters in the given string. + */ + unescape(pattern: string): string; + } } interface Micromatch { - (files: string | string[], patterns: Micromatch.Pattern | Micromatch.Pattern[]): string[]; + (files: string | string[], patterns: micromatch.Pattern | micromatch.Pattern[]): string[]; isMatch: { /** * Returns true if a file path matches the given pattern. */ - (filePath: string, pattern: Micromatch.Pattern, opts?: MicromatchOptions): boolean; + (filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean; /** * Returns a function for matching. */ - (filePath: string, opts?: MicromatchOptions): ((filePath: string) => boolean); + (filePath: string, opts?: micromatch.Options): ((filePath: string) => boolean); }; /** * Returns true if any part of a file path matches the given pattern. Think of this as "has path" versus * "is path". */ - contains(filePath: string, pattern: Micromatch.Pattern, opts?: MicromatchOptions): boolean; + contains(filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean; /** * Returns a function for matching using the supplied pattern. e.g. create your own "matcher". The advantage of * this method is that the pattern can be compiled outside of a loop. */ - matcher(pattern: Micromatch.Pattern): ((filePath: string) => boolean); + matcher(pattern: micromatch.Pattern): ((filePath: string) => boolean); /** * Returns a function that can be passed to Array#filter(). */ - filter(patterns: Micromatch.Pattern | Micromatch.Pattern[], opts?: MicromatchOptions): ((filePath: string) => boolean); + filter(patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): ((filePath: string) => boolean); /** * Returns true if a file path matches any of the given patterns. */ - any(filePath: string, patterns: Micromatch.Pattern | Micromatch.Pattern[], opts?: MicromatchOptions): boolean; + any(filePath: string, patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): boolean; /** * Returns an object with a regex-compatible string and tokens. */ - expand(pattern: string, opts?: MicromatchOptions): Glob | {pattern: string, tokens: ParseGlob.Result, options: {} /* TODO: Expand? */}; + expand(pattern: string, opts?: micromatch.Options): micromatch.Glob | {pattern: string, tokens: parseGlob.Result, options: {} /* TODO: Expand? */}; /** * Create a regular expression for matching file paths based on the given pattern. */ - makeRe(pattern: string, opts?: MicromatchOptions): RegExp; + makeRe(pattern: string, opts?: micromatch.Options): RegExp; } const micromatch: Micromatch; diff --git a/parse-glob/parse-glob-tests.ts b/parse-glob/parse-glob-tests.ts index a1b10c7e1..a7b47ded0 100644 --- a/parse-glob/parse-glob-tests.ts +++ b/parse-glob/parse-glob-tests.ts @@ -1,7 +1,7 @@ /// import parseGlob = require('parse-glob'); -var result: ParseGlob.Result = parseGlob('a/b/c/**/*.{yml,json}'); +var result: parseGlob.Result = parseGlob('a/b/c/**/*.{yml,json}'); var stringValue: string; var boolValue: boolean; diff --git a/parse-glob/parse-glob.d.ts b/parse-glob/parse-glob.d.ts index 14a73d62d..fe83c2db2 100644 --- a/parse-glob/parse-glob.d.ts +++ b/parse-glob/parse-glob.d.ts @@ -3,88 +3,88 @@ // Definitions by: glen-84 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace ParseGlob { - interface Result { - /** - * A copy of the original, unmodified glob pattern. - */ - orig: string; - /** - * An object with boolean information about the glob. - */ - is: { - /** - * True if the pattern actually is a glob pattern. - */ - glob: boolean; - /** - * True if it's a negation pattern (!/foo.js). - */ - negated: boolean; - /** - * True if it has extglobs (@(foo|bar)). - */ - extglob: boolean; - /** - * True if it has braces ({1..2} or .{txt,md}). - */ - braces: boolean; - /** - * True if it has POSIX brackets ([[:alpha:]]). - */ - brackets: boolean; - /** - * True if the pattern has a globstar (double star, **). - */ - globstar: boolean; - /** - * True if the pattern should match dotfiles. - */ - dotfile: boolean; - /** - * True if the pattern should match dot-directories (like .git). - */ - dotdir: boolean; - }; - /** - * The glob pattern part of the string, if any. - */ - glob: string; - /** - * The non-glob part of the string, if any. - */ - base: string; - /** - * File path segments. - */ - path: { - /** - * Directory. - */ - dirname: string; - /** - * File name with extension. - */ - basename: string; - /** - * File name without extension. - */ - filename: string; - /** - * File extension with dot. - */ - extname: string; - /** - * File extension without dot. - */ - ext: string; - }; - } -} - declare module 'parse-glob' { + namespace parseGlob { + interface Result { + /** + * A copy of the original, unmodified glob pattern. + */ + orig: string; + /** + * An object with boolean information about the glob. + */ + is: { + /** + * True if the pattern actually is a glob pattern. + */ + glob: boolean; + /** + * True if it's a negation pattern (!/foo.js). + */ + negated: boolean; + /** + * True if it has extglobs (@(foo|bar)). + */ + extglob: boolean; + /** + * True if it has braces ({1..2} or .{txt,md}). + */ + braces: boolean; + /** + * True if it has POSIX brackets ([[:alpha:]]). + */ + brackets: boolean; + /** + * True if the pattern has a globstar (double star, **). + */ + globstar: boolean; + /** + * True if the pattern should match dotfiles. + */ + dotfile: boolean; + /** + * True if the pattern should match dot-directories (like .git). + */ + dotdir: boolean; + }; + /** + * The glob pattern part of the string, if any. + */ + glob: string; + /** + * The non-glob part of the string, if any. + */ + base: string; + /** + * File path segments. + */ + path: { + /** + * Directory. + */ + dirname: string; + /** + * File name with extension. + */ + basename: string; + /** + * File name without extension. + */ + filename: string; + /** + * File extension with dot. + */ + extname: string; + /** + * File extension without dot. + */ + ext: string; + }; + } + } + interface ParseGlob { - (glob: string): ParseGlob.Result; + (glob: string): parseGlob.Result; } const parseGlob: ParseGlob;