From 5a36ea31c36bcd4d92b7ea0d7a07dba4524a8b72 Mon Sep 17 00:00:00 2001 From: Walter Rumsby Date: Wed, 21 Mar 2018 16:26:51 +1300 Subject: [PATCH 1/6] Add types for mem-fs --- types/mem-fs/index.d.ts | 23 +++++++++++++++++++++++ types/mem-fs/test/index.ts | 6 ++++++ types/mem-fs/tsconfig.json | 23 +++++++++++++++++++++++ types/mem-fs/tslint.json | 7 +++++++ 4 files changed, 59 insertions(+) create mode 100644 types/mem-fs/index.d.ts create mode 100644 types/mem-fs/test/index.ts create mode 100644 types/mem-fs/tsconfig.json create mode 100644 types/mem-fs/tslint.json diff --git a/types/mem-fs/index.d.ts b/types/mem-fs/index.d.ts new file mode 100644 index 0000000000..dedc40f7fc --- /dev/null +++ b/types/mem-fs/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for mem-fs 1.1 +// Project: https://github.com/SBoudrias/mem-fs +// Definitions by: My Food Bag +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import events = require('events'); +import stream = require('stream'); +import File = require('vinyl'); + +declare namespace FileSystem { + interface Store extends events.EventEmitter { + add: (file: File, content: string) => void; + each: (callback: (file: File, index: number) => void) => void; + get: (filepath: string) => File; + stream: () => stream.Transform; + } + + export function create(): Store; +} + +export = FileSystem; diff --git a/types/mem-fs/test/index.ts b/types/mem-fs/test/index.ts new file mode 100644 index 0000000000..bb925837aa --- /dev/null +++ b/types/mem-fs/test/index.ts @@ -0,0 +1,6 @@ +import * as fs from 'mem-fs'; + +const store = fs.create(); +const file = store.get('hello'); + +store.add(file, 'hahahahah'); diff --git a/types/mem-fs/tsconfig.json b/types/mem-fs/tsconfig.json new file mode 100644 index 0000000000..f0d4f87dbb --- /dev/null +++ b/types/mem-fs/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/index.ts" + ] +} diff --git a/types/mem-fs/tslint.json b/types/mem-fs/tslint.json new file mode 100644 index 0000000000..0189538855 --- /dev/null +++ b/types/mem-fs/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "export-just-namespace": false, + "strict-export-declare-modifiers": false + } +} From 4c2186d54c12b61c2554314e7c82053ff6399ecf Mon Sep 17 00:00:00 2001 From: Walter Rumsby Date: Wed, 21 Mar 2018 21:49:18 +1300 Subject: [PATCH 2/6] Generate with dts-gen --- types/mem-fs/index.d.ts | 13 ++++++------- types/mem-fs/{test/index.ts => mem-fs-tests.ts} | 0 types/mem-fs/tsconfig.json | 4 ++-- types/mem-fs/tslint.json | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-) rename types/mem-fs/{test/index.ts => mem-fs-tests.ts} (100%) diff --git a/types/mem-fs/index.d.ts b/types/mem-fs/index.d.ts index dedc40f7fc..08a3067637 100644 --- a/types/mem-fs/index.d.ts +++ b/types/mem-fs/index.d.ts @@ -1,15 +1,15 @@ // Type definitions for mem-fs 1.1 -// Project: https://github.com/SBoudrias/mem-fs +// Project: https://github.com/sboudrias/mem-fs#readme // Definitions by: My Food Bag // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import events = require('events'); import stream = require('stream'); import File = require('vinyl'); -declare namespace FileSystem { +export function create(...args: any[]): create.Store; + +export namespace create { interface Store extends events.EventEmitter { add: (file: File, content: string) => void; each: (callback: (file: File, index: number) => void) => void; @@ -17,7 +17,6 @@ declare namespace FileSystem { stream: () => stream.Transform; } - export function create(): Store; + const prototype: { + }; } - -export = FileSystem; diff --git a/types/mem-fs/test/index.ts b/types/mem-fs/mem-fs-tests.ts similarity index 100% rename from types/mem-fs/test/index.ts rename to types/mem-fs/mem-fs-tests.ts diff --git a/types/mem-fs/tsconfig.json b/types/mem-fs/tsconfig.json index f0d4f87dbb..23cb94acb6 100644 --- a/types/mem-fs/tsconfig.json +++ b/types/mem-fs/tsconfig.json @@ -6,8 +6,8 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": true, "strictFunctionTypes": true, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "test/index.ts" + "mem-fs-tests.ts" ] } diff --git a/types/mem-fs/tslint.json b/types/mem-fs/tslint.json index 0189538855..2ff396e742 100644 --- a/types/mem-fs/tslint.json +++ b/types/mem-fs/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "export-just-namespace": false, - "strict-export-declare-modifiers": false + } } From a08461c40539fb1b95492dbfea634b6cfc8e9363 Mon Sep 17 00:00:00 2001 From: Walter Rumsby Date: Thu, 22 Mar 2018 11:10:51 +1300 Subject: [PATCH 3/6] Tidy up --- types/mem-fs/index.d.ts | 16 +++++++++------- types/mem-fs/mem-fs-tests.ts | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/types/mem-fs/index.d.ts b/types/mem-fs/index.d.ts index 08a3067637..13d1c27105 100644 --- a/types/mem-fs/index.d.ts +++ b/types/mem-fs/index.d.ts @@ -3,18 +3,20 @@ // Definitions by: My Food Bag // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import events = require('events'); -import stream = require('stream'); -import File = require('vinyl'); +/// -export function create(...args: any[]): create.Store; +import { EventEmitter } from 'events'; +import { Transform } from 'stream'; +import * as File from 'vinyl'; -export namespace create { - interface Store extends events.EventEmitter { +export function create(...args: any[]): memFs.Store; + +export namespace memFs { + interface Store extends EventEmitter { add: (file: File, content: string) => void; each: (callback: (file: File, index: number) => void) => void; get: (filepath: string) => File; - stream: () => stream.Transform; + stream: () => Transform; } const prototype: { diff --git a/types/mem-fs/mem-fs-tests.ts b/types/mem-fs/mem-fs-tests.ts index bb925837aa..13a2649f19 100644 --- a/types/mem-fs/mem-fs-tests.ts +++ b/types/mem-fs/mem-fs-tests.ts @@ -4,3 +4,5 @@ const store = fs.create(); const file = store.get('hello'); store.add(file, 'hahahahah'); + +store.each((file, index) => console.log(index, file.path)); From 196d13df6f5dca28bdb6db85d87b3059033f8263 Mon Sep 17 00:00:00 2001 From: Walter Rumsby Date: Fri, 23 Mar 2018 16:09:12 +1300 Subject: [PATCH 4/6] Update based on PR comments --- types/mem-fs/mem-fs-tests.ts | 2 +- types/mem-fs/tslint.json | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/types/mem-fs/mem-fs-tests.ts b/types/mem-fs/mem-fs-tests.ts index 13a2649f19..ada05c22c7 100644 --- a/types/mem-fs/mem-fs-tests.ts +++ b/types/mem-fs/mem-fs-tests.ts @@ -5,4 +5,4 @@ const file = store.get('hello'); store.add(file, 'hahahahah'); -store.each((file, index) => console.log(index, file.path)); +store.each(file => console.dir(store.get(file.path))); diff --git a/types/mem-fs/tslint.json b/types/mem-fs/tslint.json index 2ff396e742..f93cf8562a 100644 --- a/types/mem-fs/tslint.json +++ b/types/mem-fs/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - - } + "extends": "dtslint/dt.json" } From c5e3a155758aace83ce97f5615cc1671972f2e9f Mon Sep 17 00:00:00 2001 From: Walter Rumsby Date: Sat, 24 Mar 2018 07:13:02 +1300 Subject: [PATCH 5/6] Remove prototype --- types/mem-fs/index.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/types/mem-fs/index.d.ts b/types/mem-fs/index.d.ts index 13d1c27105..da6a209bb6 100644 --- a/types/mem-fs/index.d.ts +++ b/types/mem-fs/index.d.ts @@ -18,7 +18,4 @@ export namespace memFs { get: (filepath: string) => File; stream: () => Transform; } - - const prototype: { - }; } From a9dc8167a09f03aa3c2247ece908cb4abd6c185f Mon Sep 17 00:00:00 2001 From: Walter Rumsby Date: Sat, 24 Mar 2018 07:27:28 +1300 Subject: [PATCH 6/6] Remove readme from project link --- types/mem-fs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mem-fs/index.d.ts b/types/mem-fs/index.d.ts index da6a209bb6..0cece1da38 100644 --- a/types/mem-fs/index.d.ts +++ b/types/mem-fs/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for mem-fs 1.1 -// Project: https://github.com/sboudrias/mem-fs#readme +// Project: https://github.com/sboudrias/mem-fs // Definitions by: My Food Bag // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped