Skip to content

Commit

Permalink
Workaround for testOnly type error
Browse files Browse the repository at this point in the history
  • Loading branch information
af committed Jan 2, 2021
1 parent f79ba8d commit c41eee5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"husky": {
"hooks": {
"pre-commit": "yarn lint --fix",
"pre-push": "npm test"
"pre-push": "yarn test"
}
}
}
4 changes: 1 addition & 3 deletions src/envalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ function cleanEnv<T>(
* For more context, see https://github.com/af/envalid/issues/32
*/
const testOnly = <T>(defaultValueForTests: T) => {
return process.env.NODE_ENV === 'test' ?
defaultValueForTests :
(testOnlySymbol as unknown as T) // T is not strictly correct, but prevents type errors during usage
return process.env.NODE_ENV === 'test' ? defaultValueForTests : ((testOnlySymbol as unknown) as T) // T is not strictly correct, but prevents type errors during usage
}

export { cleanEnv, testOnly }

0 comments on commit c41eee5

Please sign in to comment.