Skip to content

Commit

Permalink
Fix reporter interface type (af#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
neezer authored and af committed May 8, 2018
1 parent 0732e29 commit bf660a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion envalid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ interface CleanEnv {
readonly isProd: boolean
}

interface ReporterOptions {
errors: { [key: string]: Error }
env: any
}

interface CleanOptions {
/**
* If true, the output of cleanEnv will only contain the env vars that were specified in the validators argument.
Expand All @@ -55,7 +60,7 @@ interface CleanOptions {
* Pass in a function to override the default error handling and console output.
* See lib/reporter.js for the default implementation.
*/
reporter?: (errors: { [key: string]: Error }, env: any) => void
reporter?: (opts: ReporterOptions) => void

/**
* A function used to transform the cleaned environment object before it is returned from cleanEnv.
Expand Down
2 changes: 1 addition & 1 deletion tests/envalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cleanEnv(
{},
{
dotEnvPath: null,
reporter: (errors, e) => {
reporter: ({ errors, env: e }) => {
const errorMessage: string = errors[0].message
const errorName: string = errors[0].name
},
Expand Down

0 comments on commit bf660a9

Please sign in to comment.