Fix typescript strict issues for CosmosClient and other files

This commit is contained in:
vaidankarswapnil 2021-08-26 14:05:02 +05:30
parent 8eeda41021
commit 12503fa140
3 changed files with 15 additions and 6 deletions

View File

@ -39,8 +39,16 @@ export const tokenProvider = async (requestInfo: RequestInfo) => {
};
export const requestPlugin: Cosmos.Plugin<any> = async (requestContext, next) => {
requestContext.endpoint = new URL(configContext.PROXY_PATH, window.location.href).href;
requestContext.headers["x-ms-proxy-target"] = endpoint();
requestContext.endpoint = new URL(
configContext.PROXY_PATH ? configContext.PROXY_PATH : "",
window.location.href
).href;
if (requestContext.headers !== undefined) {
const returnValue = endpoint();
if (returnValue !== undefined) {
requestContext.headers["x-ms-proxy-target"] = returnValue;
}
}
return next(requestContext);
};
@ -60,7 +68,7 @@ export async function getTokenFromAuthService(verb: string, resourceType: string
method: "POST",
headers: {
"content-type": "application/json",
"x-ms-encrypted-auth-token": userContext.accessToken,
"x-ms-encrypted-auth-token": userContext.accessToken ? userContext.accessToken : "",
},
body: JSON.stringify({
verb,

View File

@ -28,10 +28,10 @@ export const getErrorMessage = (error: string | Error = ""): string => {
};
export const getErrorStack = (error: string | Error): string => {
return typeof error === "string" ? undefined : error.stack;
return typeof error === "string" ? "" : error.stack === undefined ? "" : error.stack;
};
const sendNotificationForError = (errorMessage: string, errorCode: number | string): void => {
const sendNotificationForError = (errorMessage: string, errorCode: number | string | undefined): void => {
if (errorCode === HttpStatusCodes.Forbidden) {
if (errorMessage?.toLowerCase().indexOf("sharedoffer is disabled for your account") > 0) {
return;

View File

@ -139,7 +139,8 @@
"./src/userContext.test.ts",
"src/Common/EntityValue.tsx",
"./src/Platform/Hosted/Components/SwitchAccount.tsx",
"./src/Platform/Hosted/Components/SwitchSubscription.tsx"
"./src/Platform/Hosted/Components/SwitchSubscription.tsx",
"./src/Common/CosmosClient.ts"
],
"include": [
"src/CellOutputViewer/transforms/**/*",