Skip to content

Commit 436b46d

Browse files
authored
Revert "Fix type of Base argument to createError (#106)" (#107)
This reverts commit 5c4b26e.
1 parent 5c4b26e commit 436b46d

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
declare function createError<C extends string, SC extends number, Arg extends unknown[] = [any?, any?, any?], Err extends Error = Error> (
1+
declare function createError<C extends string, SC extends number, Arg extends unknown[] = [any?, any?, any?]> (
22
code: C,
33
message: string,
44
statusCode: SC,
5-
Base?: new () => Err
5+
Base?: Error
66
): createError.FastifyErrorConstructor<{ code: C, statusCode: SC }, Arg>
77

8-
declare function createError<C extends string, Arg extends unknown[] = [any?, any?, any?], Err extends Error = Error> (
8+
declare function createError<C extends string, Arg extends unknown[] = [any?, any?, any?]> (
99
code: C,
1010
message: string,
1111
statusCode?: number,
12-
Base?: new () => Err
12+
Base?: Error
1313
): createError.FastifyErrorConstructor<{ code: C }, Arg>
1414

15-
declare function createError<Arg extends unknown[] = [any?, any?, any?], Err extends Error = Error> (
15+
declare function createError<Arg extends unknown[] = [any?, any?, any?]> (
1616
code: string,
1717
message: string,
1818
statusCode?: number,
19-
Base?: new () => Err
19+
Base?: Error
2020
): createError.FastifyErrorConstructor<{ code: string }, Arg>
2121

2222
type CreateError = typeof createError

types/index.test-d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,3 @@ expectError(new CustomTypedArgError6('a', 'b'))
6565
expectError(new CustomTypedArgError6('a', 'b', 'c'))
6666
CustomTypedArgError6('a', 'b', 'c', 'd')
6767
expectError(new CustomTypedArgError6('a', 'b', 'c', 'd', 'e'))
68-
69-
70-
const CustomErrorWithErrorConstructor = createError('ERROR_CODE', 'message', 500, TypeError)
71-
expectType<FastifyErrorConstructor<{ code: 'ERROR_CODE', statusCode: 500 }>>(CustomErrorWithErrorConstructor)

0 commit comments

Comments
 (0)