Skip to content

Commit

Permalink
Revert "Fix type of Base argument to createError (#106)" (#107)
Browse files Browse the repository at this point in the history
This reverts commit 5c4b26e.
  • Loading branch information
Uzlopak authored Jun 6, 2023
1 parent 5c4b26e commit 436b46d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 6 additions & 6 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
declare function createError<C extends string, SC extends number, Arg extends unknown[] = [any?, any?, any?], Err extends Error = Error> (
declare function createError<C extends string, SC extends number, Arg extends unknown[] = [any?, any?, any?]> (
code: C,
message: string,
statusCode: SC,
Base?: new () => Err
Base?: Error
): createError.FastifyErrorConstructor<{ code: C, statusCode: SC }, Arg>

declare function createError<C extends string, Arg extends unknown[] = [any?, any?, any?], Err extends Error = Error> (
declare function createError<C extends string, Arg extends unknown[] = [any?, any?, any?]> (
code: C,
message: string,
statusCode?: number,
Base?: new () => Err
Base?: Error
): createError.FastifyErrorConstructor<{ code: C }, Arg>

declare function createError<Arg extends unknown[] = [any?, any?, any?], Err extends Error = Error> (
declare function createError<Arg extends unknown[] = [any?, any?, any?]> (
code: string,
message: string,
statusCode?: number,
Base?: new () => Err
Base?: Error
): createError.FastifyErrorConstructor<{ code: string }, Arg>

type CreateError = typeof createError
Expand Down
4 changes: 0 additions & 4 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,3 @@ expectError(new CustomTypedArgError6('a', 'b'))
expectError(new CustomTypedArgError6('a', 'b', 'c'))
CustomTypedArgError6('a', 'b', 'c', 'd')
expectError(new CustomTypedArgError6('a', 'b', 'c', 'd', 'e'))


const CustomErrorWithErrorConstructor = createError('ERROR_CODE', 'message', 500, TypeError)
expectType<FastifyErrorConstructor<{ code: 'ERROR_CODE', statusCode: 500 }>>(CustomErrorWithErrorConstructor)

0 comments on commit 436b46d

Please sign in to comment.