From e74f97b79adc88c7c105cff13b52b0fe1416e927 Mon Sep 17 00:00:00 2001 From: Evan Shortiss Date: Wed, 12 Feb 2020 15:13:15 -0800 Subject: [PATCH] 6.0.1 - Typings fix (#100) * Fix typings for the `default(value)` function. --- CHANGELOG.md | 3 +++ env-var.d.ts | 4 ++-- example/typescript.ts | 2 +- package.json | 4 ++-- tsconfig.json | 5 +++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2471d4f..cbcbab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 6.0.1 (09/01/20) +* Fix typings for the `default(value)` function. + ## 6.0.0 (09/01/20) * Add support for setting an example value via the `example(string)` function. * Passing default values is now performed using the `default(string)` function. diff --git a/env-var.d.ts b/env-var.d.ts index e4311e9..72ea521 100644 --- a/env-var.d.ts +++ b/env-var.d.ts @@ -19,7 +19,7 @@ interface IPresentVariable { * Set a default value for this variable. This will be used if a value is not * set in the process environment */ - default: (value: string) => IPresentVariable; + default: (value: string|number|Record|Array) => IPresentVariable; /** * Ensures the variable is set on process.env. If it's not set an exception @@ -136,7 +136,7 @@ interface IOptionalVariable { * Set a default value for this variable. This will be used if a value is not * set in the process environment */ - default: (value: string) => IPresentVariable; + default: (value: string|number|Record|Array) => IPresentVariable; /** * Ensures the variable is set on process.env. If it's not set an exception will be thrown. diff --git a/example/typescript.ts b/example/typescript.ts index 0545e1a..e561e12 100644 --- a/example/typescript.ts +++ b/example/typescript.ts @@ -20,6 +20,6 @@ if (!url) { console.log('url is', url) // Integers -const requiredInt = env.get('AN_INTEGER').required().asInt() +const requiredInt = env.get('AN_INTEGER').default(10).required().asInt() console.log('the integer was', requiredInt) diff --git a/package.json b/package.json index 19496e1..66deb00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "env-var", - "version": "6.0.0", + "version": "6.0.1", "description": "Verification, sanatization, and type coercion for environment variables in Node.js", "main": "env-var.js", "typings": "env-var.d.ts", @@ -60,7 +60,7 @@ "mocha-lcov-reporter": "~1.3.0", "nyc": "~15.0.0", "standard": "~14.3.0", - "typescript": "~3.1.3" + "typescript": "~3.7.5" }, "engines": { "node": ">=8" diff --git a/tsconfig.json b/tsconfig.json index 4728463..4b63f84 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,8 @@ "target": "es5", "moduleResolution": "node", "skipLibCheck": true, - "strict": true + "strict": true, + "strictNullChecks": true }, - "files": ["test/types/index.ts"] + "files": ["test/types/index.ts", "example/typescript.ts"] }