From bec9ece0cca0aa402699048984e3ea27cfa89344 Mon Sep 17 00:00:00 2001 From: Lucas de Almeida Carotta Date: Fri, 1 Feb 2019 03:11:53 -0200 Subject: [PATCH] Add TypeScript definition (#13) Co-authored-by: Sindre Sorhus --- index.d.ts | 19 +++++++++++++++++++ index.test-d.ts | 5 +++++ package.json | 6 ++++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 index.d.ts create mode 100644 index.test-d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..c7dc831 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,19 @@ +export interface EnvironmentVariables { + readonly [key: string]: string; +} + +/** + * Get the environment variables defined in your dotfiles. + * + * @param shell - The shell to read the environment variables from. Default: User default shell. + * @returns The environment variables. + */ +export function sync(shell?: string): EnvironmentVariables; + +/** + * Get the environment variables defined in your dotfiles. + * + * @param shell - The shell to read the environment variables from. Default: User default shell. + * @returns The environment variables. + */ +export default function shellEnv(shell?: string): Promise; diff --git a/index.test-d.ts b/index.test-d.ts new file mode 100644 index 0000000..a5ef803 --- /dev/null +++ b/index.test-d.ts @@ -0,0 +1,5 @@ +import {expectType} from 'tsd-check'; +import shellEnv, {sync, EnvironmentVariables} from '.'; + +expectType(sync()); +expectType(await shellEnv()); diff --git a/package.json b/package.json index 2448148..a529455 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,11 @@ "node": ">=6" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd-check" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "keywords": [ "env", @@ -39,6 +40,7 @@ }, "devDependencies": { "ava": "*", + "tsd-check": "^0.3.0", "xo": "*" } }