Skip to content

Commit 490ac35

Browse files
committed
chore: update tsconfig
1 parent 932581d commit 490ac35

File tree

2 files changed

+32
-43
lines changed

2 files changed

+32
-43
lines changed

src/custom-instance.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Or use 'ky'
99
*/
1010

11-
import Axios, { AxiosError, AxiosRequestConfig } from 'axios';
11+
import Axios, { AxiosError, type AxiosRequestConfig } from "axios";
1212

1313
export const AXIOS_INSTANCE = Axios.create();
1414

@@ -18,7 +18,7 @@ export const AXIOS_INSTANCE = Axios.create();
1818
* @param token access token
1919
*/
2020
export const setAuthToken = (token: string) => {
21-
AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;
21+
AXIOS_INSTANCE.defaults.headers.common["Authorization"] = `Bearer ${token}`;
2222
};
2323

2424
/**
@@ -31,17 +31,19 @@ export const setBaseUrl = (baseUrl: string) => {
3131

3232
export const customInstance = <TReturn>(
3333
config: AxiosRequestConfig,
34-
options?: AxiosRequestConfig,
34+
options?: AxiosRequestConfig
3535
): Promise<TReturn> => {
3636
const source = Axios.CancelToken.source();
3737

38-
const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(
39-
({ data }) => data,
40-
);
38+
const promise = AXIOS_INSTANCE({
39+
...config,
40+
...options,
41+
cancelToken: source.token,
42+
}).then(({ data }) => data);
4143

4244
// @ts-expect-error need to add a cancel method to the promise
4345
promise.cancel = () => {
44-
source.cancel('Query was cancelled');
46+
source.cancel("Query was cancelled");
4547
};
4648

4749
return promise;

tsconfig.json

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,29 @@
11
{
2-
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
3-
"include": [
4-
"src",
5-
"types"
6-
],
72
"compilerOptions": {
8-
"module": "esnext",
9-
"lib": [
10-
"dom",
11-
"esnext"
12-
],
13-
"importHelpers": true,
14-
// output .d.ts declaration files for consumers
15-
"declaration": true,
16-
// output .js.map sourcemap files for consumers
17-
"sourceMap": true,
18-
// match output dir to input dir. e.g. dist/index instead of dist/src/index
19-
"rootDir": "./src",
20-
// stricter type-checking for stronger correctness. Recommended by TS
21-
"strict": true,
22-
// linter checks for common issues
23-
"noImplicitReturns": true,
24-
"noFallthroughCasesInSwitch": true,
25-
// noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
26-
"noUnusedLocals": true,
27-
"noUnusedParameters": false,
28-
// use Node's module resolution algorithm, instead of the legacy TS one
29-
"moduleResolution": "node",
30-
// transpile JSX to React.createElement
31-
"jsx": "react",
32-
// interop between ESM and CJS modules. Recommended by TS
3+
/* Base Options: */
334
"esModuleInterop": true,
34-
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
355
"skipLibCheck": true,
36-
// error out if import and file system have a casing mismatch. Recommended by TS
37-
"forceConsistentCasingInFileNames": true,
38-
// `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
6+
"target": "es2022",
7+
"allowJs": true,
8+
"resolveJsonModule": true,
9+
"moduleDetection": "force",
10+
"isolatedModules": true,
11+
"verbatimModuleSyntax": true,
12+
13+
/* Strictness */
14+
"strict": true,
15+
"noUncheckedIndexedAccess": true,
16+
"noImplicitOverride": true,
17+
18+
/* AND if you're building for a library: */
19+
"declaration": true,
20+
"declarationMap": true,
21+
22+
/* If NOT transpiling with TypeScript: */
23+
"module": "preserve",
3924
"noEmit": true,
40-
"baseUrl": "./src"
25+
26+
/* If your code runs in the DOM: */
27+
"lib": ["es2022", "dom", "dom.iterable"],
4128
}
42-
}
29+
}

0 commit comments

Comments
 (0)