From 5a3d0a3234d77361a1bc7cedee2da1e11df08e2c Mon Sep 17 00:00:00 2001 From: Dmitriy Mozgovoy Date: Sat, 28 Jan 2023 15:58:56 +0200 Subject: [PATCH] fix(types): fixed `CommonRequestHeadersList` & `CommonResponseHeadersList` types to be private in commonJS; (#5503) --- index.d.cts | 14 +++++++++----- index.d.ts | 8 ++++++-- package.json | 9 ++++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/index.d.cts b/index.d.cts index e91217b7c1..c0f89bca87 100644 --- a/index.d.cts +++ b/index.d.cts @@ -10,6 +10,12 @@ type MethodsHeaders = Partial<{ type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean; +type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent'| 'Content-Encoding' | 'Authorization'; + +type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream'; + +type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding'; + declare class AxiosHeaders { constructor( headers?: RawAxiosHeaders | AxiosHeaders @@ -41,7 +47,7 @@ declare class AxiosHeaders { static concat(...targets: Array): AxiosHeaders; - setContentType(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; + setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; getContentType(parser?: RegExp): RegExpExecArray | null; getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; hasContentType(matcher?: AxiosHeaderMatcher): boolean; @@ -200,16 +206,14 @@ type InternalAxiosError = AxiosError; declare namespace axios { type AxiosError = InternalAxiosError; - type CommonRequestHeadersList = 'Accept' | 'Content-Type' | 'Content-Length' | 'User-Agent'| 'Content-Encoding'; - type RawAxiosRequestHeaders = Partial; type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders; - type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding'; - type RawCommonResponseHeaders = { [Key in CommonResponseHeadersList]: AxiosHeaderValue; } & { diff --git a/index.d.ts b/index.d.ts index 0249403c5c..8c068b9a34 100644 --- a/index.d.ts +++ b/index.d.ts @@ -42,7 +42,7 @@ export class AxiosHeaders { static concat(...targets: Array): AxiosHeaders; - setContentType(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; + setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; getContentType(parser?: RegExp): RegExpExecArray | null; getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; hasContentType(matcher?: AxiosHeaderMatcher): boolean; @@ -75,10 +75,14 @@ export class AxiosHeaders { [Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>; } -type CommonRequestHeadersList = 'Accept' | 'Content-Type' | 'Content-Length' | 'User-Agent' | 'Content-Encoding' | 'Authorization'; +type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent' | 'Content-Encoding' | 'Authorization'; + +type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream'; export type RawAxiosRequestHeaders = Partial; export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders; diff --git a/package.json b/package.json index 255ee2c34f..7e85484167 100644 --- a/package.json +++ b/package.json @@ -190,8 +190,15 @@ } }, "commitlint": { + "rules": { + "header-max-length": [ + 2, + "always", + 130 + ] + }, "extends": [ "@commitlint/config-conventional" ] } -} \ No newline at end of file +}