Skip to content

Commit

Permalink
fix: fix resolvePath return type (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbassett committed Jun 19, 2023
1 parent e075161 commit a7ed66a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/_utils.ts
Expand Up @@ -6,7 +6,10 @@ export function normalizeSlash(string_) {
return string_.replace(/\\/g, "/");
}

export function pcall(function_, ...arguments_) {
export function pcall<TFn extends (...args: any[]) => any>(
function_: TFn,
...arguments_: Parameters<TFn>
): Promise<ReturnType<TFn>> {
try {
return Promise.resolve(function_(...arguments_)).catch((error) =>
perr(error)
Expand Down
7 changes: 5 additions & 2 deletions src/resolve.ts
Expand Up @@ -132,11 +132,14 @@ export function resolve(id: string, options?: ResolveOptions): Promise<string> {
return pcall(resolveSync, id, options);
}

export function resolvePathSync(id: string, options?: ResolveOptions) {
export function resolvePathSync(id: string, options?: ResolveOptions): string {
return fileURLToPath(resolveSync(id, options));
}

export function resolvePath(id: string, options?: ResolveOptions) {
export function resolvePath(
id: string,
options?: ResolveOptions
): Promise<string> {
return pcall(resolvePathSync, id, options);
}

Expand Down

0 comments on commit a7ed66a

Please sign in to comment.