Skip to content

Commit f0291ef

Browse files
authored
nodenext compatibility (#88)
1 parent d61f38e commit f0291ef

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ function createError (code, message, statusCode = 500, Base = Error) {
4848
}
4949

5050
module.exports = createError
51+
module.exports.default = createError
52+
module.exports.createError = createError

types/index.d.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
export = createError
2-
3-
declare function createError (
4-
code: string,
5-
message: string,
6-
statusCode?: number,
7-
Base?: Error
8-
): createError.FastifyErrorConstructor
1+
type CreateError = (code: string, message: string, statusCode?: number, Base?: Error) => createError.FastifyErrorConstructor
92

103
declare namespace createError {
11-
interface FastifyError extends Error {
4+
export interface FastifyError extends Error {
125
code: string;
136
name: string;
147
statusCode?: number;
158
}
169

17-
interface FastifyErrorConstructor {
10+
export interface FastifyErrorConstructor {
1811
new(a?: any, b?: any, c?: any): FastifyError;
1912
(a?: any, b?: any, c?: any): FastifyError;
2013
readonly prototype: FastifyError;
2114
}
15+
16+
export const createError: CreateError
17+
export { createError as default }
2218
}
19+
20+
declare function createError(...params: Parameters<CreateError>): ReturnType<CreateError>
21+
export = createError

0 commit comments

Comments
 (0)