Skip to content

Commit

Permalink
fix(types): fix some dts issues
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Feb 3, 2020
1 parent db41c24 commit e1ce523
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare module 'reqresnext' {
}
type IData = any
interface IDescriptor {
[key: any]: any
[key: string]: any
}
type ICookie = {
name: string;
Expand All @@ -25,7 +25,10 @@ declare module 'reqresnext' {
type IHeaderName = string
type IHeaderValue = string
type IHeadersMap = {
[key: IHeaderName]: IHeaderValue
[key: string]: IHeaderValue
}
export type IHeaders = {
[key: string]: string | string[]
}
type IHeaderSetter = {
(field: IHeadersMap | IHeaderName, value?: IHeaderValue): void
Expand All @@ -45,6 +48,8 @@ declare module 'reqresnext' {
[key: string]: any;
req: IRequest | Object;
cookie: ICookieSetter;
writeHead (code: number, headers: IHeaders): IAny,
end (data?: string, encoding?: string, cb?: Function): IResponse
}
type IConnection = {
encrypted?: boolean
Expand Down Expand Up @@ -92,7 +97,7 @@ declare module 'reqresnext' {
interface IResponseOpts {
headers: IHeadersMap;
}
class Request {
class Request implements IRequest {
[key: string]: any
cookie: ICookieSetter
header: IHeaderSetter
Expand All @@ -106,22 +111,23 @@ declare module 'reqresnext' {
_flush: Function
_readableState: IAny
socket: ISocket
constructor (input?: IRawOptions): IRequest
constructor (input?: IRawOptions)
}
export class Response {
export class Response implements IResponse{
[key: string]: any
cookie: ICookieSetter
header: IHeaderSetter
headers: IHeadersMap
writeHead (code: number, headers: IHeaders): IAny
_headers: IAny
status: IStatusSetter
app: IApp
req: IRequest | Object
body: IDescriptor
emit: Function
write: Function
end: Function
constructor (input?: IRawOptions): IResponse
end: (data?: string, encoding?: string, cb?: Function) => IResponse
constructor (input?: IRawOptions)
}
export const reqresnext: {
(reqOpts?: IRawOptions, resOpts?: IRawOptions, next?: Function): {
Expand All @@ -132,6 +138,7 @@ declare module 'reqresnext' {
Request: typeof Request,
Response: typeof Response
}


//@ts-ignore
export = reqresnext
}

0 comments on commit e1ce523

Please sign in to comment.