Skip to content

Commit

Permalink
Add TypeScript definition (#13)
Browse files Browse the repository at this point in the history

Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
Fazendaaa and sindresorhus committed Feb 1, 2019
1 parent b4b7dea commit bec9ece
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
19 changes: 19 additions & 0 deletions 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<EnvironmentVariables>;
5 changes: 5 additions & 0 deletions index.test-d.ts
@@ -0,0 +1,5 @@
import {expectType} from 'tsd-check';
import shellEnv, {sync, EnvironmentVariables} from '.';

expectType<EnvironmentVariables>(sync());
expectType<EnvironmentVariables>(await shellEnv());
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -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",
Expand All @@ -39,6 +40,7 @@
},
"devDependencies": {
"ava": "*",
"tsd-check": "^0.3.0",
"xo": "*"
}
}

0 comments on commit bec9ece

Please sign in to comment.