common: Enable TypeScript strict for packages/auth-fetch (#1493)

* Add tsconfig strict to packages/auth-fetch

* Refactor switch case

* Revert "Refactor switch case"

This reverts commit b5004664bb.

* Revert switch changes
This commit is contained in:
Long Zheng
2024-06-04 10:48:38 +10:00
committed by GitHub
parent 9a770e9dc9
commit cf1c500e9d
4 changed files with 9 additions and 8 deletions

View File

@@ -41,7 +41,7 @@ const StreamParser: FetchParser<IncomingMessage> = {
}
}
export function getHttpFetchParser(responseType: HttpFetchResponseType) {
export function getHttpFetchParser(responseType: HttpFetchResponseType | undefined) {
switch (responseType) {
case 'json':
return JSONParser;
@@ -53,7 +53,7 @@ export function getHttpFetchParser(responseType: HttpFetchResponseType) {
return BufferParser;
}
export function httpFetchParseIncomingMessage(readable: IncomingMessage, responseType: HttpFetchResponseType) {
export function httpFetchParseIncomingMessage(readable: IncomingMessage, responseType: HttpFetchResponseType | undefined) {
return getHttpFetchParser(responseType).parse(readable);
}

View File

@@ -62,7 +62,7 @@ export type fetcher<B, M> = <T extends HttpFetchOptions<B>>(options: T) => Promi
>>;
export function getHttpFetchAccept(responseType: HttpFetchResponseType) {
export function getHttpFetchAccept(responseType: HttpFetchResponseType | undefined) {
switch (responseType) {
case 'json':
return 'application/json';
@@ -89,7 +89,7 @@ export function setHeader(headers: [string, string][], key: string, value: strin
headers.push([key, value]);
}
export function setDefaultHttpFetchAccept(headers: [string, string][], responseType: HttpFetchResponseType) {
export function setDefaultHttpFetchAccept(headers: [string, string][], responseType: HttpFetchResponseType | undefined) {
if (hasHeader(headers, 'Accept'))
return;
const accept = getHttpFetchAccept(responseType);
@@ -97,7 +97,7 @@ export function setDefaultHttpFetchAccept(headers: [string, string][], responseT
setHeader(headers, 'Accept', accept);
}
export function createHeadersArray(headers: HeadersInit): [string, string][] {
export function createHeadersArray(headers: HeadersInit | undefined): [string, string][] {
const headersArray: [string, string][] = [];
if (!headers)
return headersArray;
@@ -144,7 +144,7 @@ export function createStringOrBufferBody(headers: [string, string][], body: any)
return body;
}
export async function domFetchParseIncomingMessage(response: Response, responseType: HttpFetchResponseType) {
export async function domFetchParseIncomingMessage(response: Response, responseType: HttpFetchResponseType | undefined) {
switch (responseType) {
case 'json':
return response.json();