From b380d77c8cedc2c4b1d2a9023ad153f8ccc64214 Mon Sep 17 00:00:00 2001 From: Avi Vahl Date: Sun, 9 Apr 2017 13:29:32 +0300 Subject: [PATCH] Match klaw's Options with implementation `pathSorter` and `filter` are callbacks passed to sort/filter of an array of *strings* (that is returned by fs.readdir). See: https://github.com/jprichardson/node-klaw/blob/master/src/index.js#L44 I saw the actual runtime failure when using the current types (a.path/stats is undefined in that context), which made me check the actual implementation. --- types/klaw/index.d.ts | 4 ++-- types/klaw/klaw-tests.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/klaw/index.d.ts b/types/klaw/index.d.ts index e996a90033..cbe78af067 100644 --- a/types/klaw/index.d.ts +++ b/types/klaw/index.d.ts @@ -22,9 +22,9 @@ declare module "klaw" { interface Options extends ReadableOptions { queueMethod?: QueueMethod - pathSorter?: (a: Array) => Array + pathSorter?: (pathA: string, pathB: string) => number fs?: any // fs or mock-fs - filter?: (a: Item) => boolean + filter?: (path: string) => boolean } type Event = "close" | "data" | "end" | "readable" | "error" diff --git a/types/klaw/klaw-tests.ts b/types/klaw/klaw-tests.ts index acd8b2fcbf..2487aafd85 100644 --- a/types/klaw/klaw-tests.ts +++ b/types/klaw/klaw-tests.ts @@ -32,8 +32,8 @@ klaw('/some/dir') // README.md: Example (ignore hidden directories): -var filterFunc = function(item: klaw.Item): boolean { - var basename = path.basename(item.path) +var filterFunc = function(item: string): boolean { + var basename = path.basename(item); return basename === '.' || basename[0] !== '.' }