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));