Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

chore(util): remove argument type for err #3451

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ export function runFilenameOrFn_(
filenameOrFn = require(resolve(configDir, filenameOrFn));
}
if (typeof filenameOrFn === 'function') {
let results =
when(filenameOrFn.apply(null, args), null, (err: string | Error) => {
if (typeof err === 'string') {
err = new Error(err);
} else {
err = err as Error;
if (err.stack) {
err.stack = new Error().stack;
}
}
err.stack = exports.filterStackTrace(err.stack);
throw err;
});
let results = when(filenameOrFn.apply(null, args), null, (err) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised no type is needed for err but alright

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into this and DefinitelyTyped q.when has defined a callback onRejected?: (reason: any).

if (typeof err === 'string') {
err = new Error(err);
} else {
err = err as Error;
if (err.stack) {
err.stack = new Error().stack;
}
}
err.stack = exports.filterStackTrace(err.stack);
throw err;
});
resolvePromise(results);
} else {
resolvePromise(undefined);
Expand Down