From a87ea5342ea2fbb0297eab0394c8d4b486c1d28e Mon Sep 17 00:00:00 2001 From: Tomer Aberbach Date: Fri, 17 May 2024 13:28:22 -0400 Subject: [PATCH] Fix incorrect TypeScript type (#1) --- index.d.ts | 2 +- index.test-d.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 523f354..82bfb5a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -31,7 +31,7 @@ try { } ``` */ -export default function functionTimeout(function_: T, options: Options): T; // eslint-disable-line @typescript-eslint/ban-types +export default function functionTimeout(function_: T, options?: Options): T; // eslint-disable-line @typescript-eslint/ban-types /** Returns a boolean for whether the given error is a timeout error. diff --git a/index.test-d.ts b/index.test-d.ts index 98ca6b8..b33e4ae 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,6 +1,8 @@ import {expectType} from 'tsd'; import functionTimeout from './index.js'; -const function_ = functionTimeout((number: number) => number * 2, {timeout: 100}); +const function1_ = functionTimeout((number: number) => number * 2, {timeout: 100}); +expectType(function1_(2)); -expectType(function_(2)); +const function2_ = functionTimeout((number: number) => number * 2); +expectType(function2_(2));