mirror of
https://github.com/koush/scrypted.git
synced 2026-02-28 08:22:29 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user