Skip to content

Commit

Permalink
Fix TypeScript return type
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
sindresorhus committed Aug 16, 2022
1 parent b05b835 commit dea1a16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ console.log(await packageDirectory());
//=> '/Users/sindresorhus/foo'
```
*/
export function packageDirectory(options?: Options): Promise<string>;
export function packageDirectory(options?: Options): Promise<string | undefined>;

/**
Synchronously find the root directory of a Node.js project or npm package.
Expand All @@ -55,4 +55,4 @@ console.log(packageDirectorySync());
//=> '/Users/sindresorhus/foo'
```
*/
export function packageDirectorySync(options?: Options): string;
export function packageDirectorySync(options?: Options): string | undefined;
4 changes: 2 additions & 2 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expectType} from 'tsd';
import {packageDirectory, packageDirectorySync} from './index.js';

expectType<Promise<string>>(packageDirectory({cwd: '/Users/project/pkg-dir'}));
expectType<string>(packageDirectorySync({cwd: '/Users/project/pkg-dir'}));
expectType<Promise<string | undefined>>(packageDirectory({cwd: '/Users/project/pkg-dir'}));
expectType<string | undefined>(packageDirectorySync({cwd: '/Users/project/pkg-dir'}));

0 comments on commit dea1a16

Please sign in to comment.