Skip to content

Commit

Permalink
upgrade typescript, fix axios BCs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-cat committed Nov 16, 2023
1 parent a266f47 commit e660b98
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"url": "https://github.com/configcat/nuxt-sdk/issues"
},
"dependencies": {
"axios": "^1.6.2",
"axios": "^1.6.0",
"configcat-common": "^8.1.1",
"tslib": "^2.4.1"
},
Expand Down Expand Up @@ -75,7 +75,7 @@
"karma-webpack": "^5.0.0",
"mocha": "^10.2.0",
"ts-loader": "^9.3.1",
"typescript": "^4.0.2",
"typescript": "^5.2.2",
"webpack": "^5.77.0",
"webpack-auto-inject-version": "^1.2.2",
"webpack-cli": "^4.10.0"
Expand Down
10 changes: 5 additions & 5 deletions src/ConfigFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FetchError } from "configcat-common";
export class HttpConfigFetcher implements IConfigFetcher {
async fetchLogic(options: OptionsBase, lastEtag: string | null): Promise<IFetchResponse> {
// If we are not running in browser set the If-None-Match header.
const headers: AxiosRequestHeaders = typeof window !== "undefined" || !lastEtag
const headers: {} = typeof window !== "undefined" || !lastEtag
// NOTE: It's intentional that we don't specify the If-None-Match header.
// The browser automatically handles it, adding it manually would cause an unnecessary CORS OPTIONS request.
? {}
Expand Down Expand Up @@ -52,10 +52,10 @@ export class HttpConfigFetcher implements IConfigFetcher {
throw err;
}

const { status: statusCode, statusText: reasonPhrase } = response;
if (response.status === 200) {
const eTag = response.headers.etag as string;
return { statusCode, reasonPhrase, eTag, body: response.data };
const { status: statusCode, statusText: reasonPhrase } = response!;
if (response!.status === 200) {
const eTag = response!.headers.etag as string;
return { statusCode, reasonPhrase, eTag, body: response!.data };
}

return { statusCode, reasonPhrase };
Expand Down
6 changes: 3 additions & 3 deletions test/HttpTests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosError } from "axios";
import axios, { AxiosError, InternalAxiosRequestConfig } from "axios";
import AxiosMockAdapter, { } from "axios-mock-adapter";
import { assert } from "chai";
import { LogLevel } from "../src/index";
Expand All @@ -17,7 +17,7 @@ describe("HTTP tests", () => {
try {
axiosMock.onGet().reply(async config => {
await new Promise<any>(resolve => setTimeout(resolve, requestTimeoutMs));
throw new AxiosError(`timeout of ${config.timeout}ms exceeded`, "ECONNABORTED", config, {}, void 0);
throw new AxiosError(`timeout of ${config.timeout}ms exceeded`, "ECONNABORTED", config as InternalAxiosRequestConfig, {}, void 0);
});

const logger = new FakeLogger();
Expand Down Expand Up @@ -105,7 +105,7 @@ describe("HTTP tests", () => {

try {
axiosMock.onGet().reply(config => {
throw new AxiosError(errorMessage, "ECONNABORTED", config, {}, void 0);
throw new AxiosError(errorMessage, "ECONNABORTED", config as InternalAxiosRequestConfig, {}, void 0);
});

const logger = new FakeLogger();
Expand Down

0 comments on commit e660b98

Please sign in to comment.