From cd8e349fe7aa27a8445ab7c03d993dff0efdae95 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 28 Jun 2017 11:18:37 +0200 Subject: [PATCH 1/5] feat(globby): add typings for `globby` --- types/globby/globby-tests.ts | 27 +++++++++++++++++++++++++++ types/globby/index.d.ts | 17 +++++++++++++++++ types/globby/tsconfig.json | 22 ++++++++++++++++++++++ types/globby/tslint.json | 1 + 4 files changed, 67 insertions(+) create mode 100644 types/globby/globby-tests.ts create mode 100644 types/globby/index.d.ts create mode 100644 types/globby/tsconfig.json create mode 100644 types/globby/tslint.json diff --git a/types/globby/globby-tests.ts b/types/globby/globby-tests.ts new file mode 100644 index 0000000000..0e08024c63 --- /dev/null +++ b/types/globby/globby-tests.ts @@ -0,0 +1,27 @@ +// + +import { IOptions } from 'glob'; + +import * as globby from "globby"; + +(async () => { + let result: string[]; + result = await globby('*.tmp') + result = await globby(['a.tmp', '*.tmp', '!{c,d,e}.tmp']) + + result = globby.sync('*.tmp') + result = globby.sync(['a.tmp', '*.tmp', '!{c,d,e}.tmp']) + + result = await globby('*.tmp', Object.freeze({ignore: Object.freeze([])})) + result = globby.sync('*.tmp', Object.freeze({ignore: Object.freeze([])})) +})() + + +const tasks: Array<{ + pattern: string, + options: IOptions +}> = globby.generateGlobTasks(['*.tmp', '!b.tmp'], {ignore: ['c.tmp']}); + +console.log(globby.hasMagic('**') === true); +console.log(globby.hasMagic(['**', 'path1', 'path2']) === true); +console.log(globby.hasMagic(['path1', 'path2']) === false); diff --git a/types/globby/index.d.ts b/types/globby/index.d.ts new file mode 100644 index 0000000000..a469cc3a0b --- /dev/null +++ b/types/globby/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for globby 0.6 +// Project: https://github.com/sindresorhus/globby#readme +// Definitions by: Douglas Duteil +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { IOptions } from 'glob'; + +declare function globby(patterns: string | string[], options?: Partial): Promise; + +declare namespace globby { + function sync(patterns: string | string[], options?: Partial): string[]; + function generateGlobTasks(patterns: string | string[], options?: Partial): Array<{pattern: string, options: IOptions}>; + function hasMagic(patterns: string | string[], options?: Partial): boolean; +} + +export = globby; diff --git a/types/globby/tsconfig.json b/types/globby/tsconfig.json new file mode 100644 index 0000000000..fd75c832f1 --- /dev/null +++ b/types/globby/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "globby-tests.ts" + ] +} diff --git a/types/globby/tslint.json b/types/globby/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/globby/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 4afe9ac8321711d8258dd78520e91425e1af7054 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 28 Jun 2017 11:28:16 +0200 Subject: [PATCH 2/5] chore(globby): test on all TypeScript versions --- types/globby/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/globby/index.d.ts b/types/globby/index.d.ts index a469cc3a0b..8452dc36ff 100644 --- a/types/globby/index.d.ts +++ b/types/globby/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/sindresorhus/globby#readme // Definitions by: Douglas Duteil // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 import { IOptions } from 'glob'; From 9d37d490249c857a9a4ad191f5f5a0179dc7d7b1 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 28 Jun 2017 11:28:46 +0200 Subject: [PATCH 3/5] fix(globby): lint error --- types/globby/globby-tests.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/types/globby/globby-tests.ts b/types/globby/globby-tests.ts index 0e08024c63..0722b5fb37 100644 --- a/types/globby/globby-tests.ts +++ b/types/globby/globby-tests.ts @@ -1,21 +1,18 @@ -// - import { IOptions } from 'glob'; import * as globby from "globby"; (async () => { let result: string[]; - result = await globby('*.tmp') - result = await globby(['a.tmp', '*.tmp', '!{c,d,e}.tmp']) + result = await globby('*.tmp'); + result = await globby(['a.tmp', '*.tmp', '!{c,d,e}.tmp']); - result = globby.sync('*.tmp') - result = globby.sync(['a.tmp', '*.tmp', '!{c,d,e}.tmp']) - - result = await globby('*.tmp', Object.freeze({ignore: Object.freeze([])})) - result = globby.sync('*.tmp', Object.freeze({ignore: Object.freeze([])})) -})() + result = globby.sync('*.tmp'); + result = globby.sync(['a.tmp', '*.tmp', '!{c,d,e}.tmp']); + result = await globby('*.tmp', Object.freeze({ignore: Object.freeze([])})); + result = globby.sync('*.tmp', Object.freeze({ignore: Object.freeze([])})); +})(); const tasks: Array<{ pattern: string, From 23bb7eed66e50b535c4ce78e1247c59bbb0781fe Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 28 Jun 2017 11:35:01 +0200 Subject: [PATCH 4/5] fix(globby): remove unnecessary "Partial" --- types/globby/index.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/types/globby/index.d.ts b/types/globby/index.d.ts index 8452dc36ff..4752b3d6ad 100644 --- a/types/globby/index.d.ts +++ b/types/globby/index.d.ts @@ -2,15 +2,17 @@ // Project: https://github.com/sindresorhus/globby#readme // Definitions by: Douglas Duteil // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import { IOptions } from 'glob'; -declare function globby(patterns: string | string[], options?: Partial): Promise; +declare function globby(patterns: string | string[], options?: IOptions): Promise; declare namespace globby { - function sync(patterns: string | string[], options?: Partial): string[]; - function generateGlobTasks(patterns: string | string[], options?: Partial): Array<{pattern: string, options: IOptions}>; - function hasMagic(patterns: string | string[], options?: Partial): boolean; + function sync(patterns: string | string[], options?: IOptions): string[]; + function generateGlobTasks(patterns: string | string[], options?: IOptions): Array<{pattern: string, options: IOptions}>; + function hasMagic(patterns: string | string[], options?: IOptions): boolean; } export = globby; + From 5e53b881264a9c9ea0f0019911bfd3aced29acd2 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 28 Jun 2017 11:38:23 +0200 Subject: [PATCH 5/5] style(globby): remove consecutive blank lines --- types/globby/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/globby/index.d.ts b/types/globby/index.d.ts index 4752b3d6ad..d06091551c 100644 --- a/types/globby/index.d.ts +++ b/types/globby/index.d.ts @@ -15,4 +15,3 @@ declare namespace globby { } export = globby; -