no-explicit-any 등록

This commit is contained in:
2023-08-06 14:27:30 +00:00
parent 31fa264160
commit 4b6d48850e
6 changed files with 30 additions and 3 deletions
+4 -1
View File
@@ -10,6 +10,9 @@ module.exports = {
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
ecmaVersion: 'latest',
},
rules: {
"@typescript-eslint/no-explicit-any": "warn",
}
}
View File
+11
View File
@@ -9,17 +9,26 @@ import { type ClassTransformOptions, plainToInstance } from "class-transformer";
export type APINamespace = {
[key: string]: APINamespace
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ClassType<GET<any, any, any>>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ClassType<POST<any, any, any>>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ClassType<PUT<any, any, any>>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ClassType<DELETE<any, any, any>>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ClassType<PATCH<any, any, any>>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ClassType<HEAD<any, any, any>>
;
}
type ValidatorType<T> = T extends undefined ? undefined : ClassType<T>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AnyAPIExecuter = APIExecuter<any, any, any>;
export abstract class APIExecuter<R extends ValidResponse, E extends InvalidResponse, Q extends RawArgType>{
readonly abstract reqType: HttpMethod;
readonly abstract argValidator?: ValidatorType<Q>;
@@ -106,6 +115,8 @@ export function raiseError(reason: string, recovery?: recoveryMethod): InvalidRe
};
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ClassType<T> = new (...args: any[]) => T;
export type APIServerType<T extends Callable> =
+2 -2
View File
@@ -1,7 +1,7 @@
import { Router } from 'express';
import type { APIExecuter, APINamespace } from './defs.js';
import type { AnyAPIExecuter, APINamespace } from './defs.js';
export function buildAPISystem<N extends APINamespace, Q extends APIExecuter<any, any, any>>(api: N | Q): Router {
export function buildAPISystem<N extends APINamespace, Q extends AnyAPIExecuter>(api: N | Q): Router {
const router = Router();
for (const [key, value] of Object.entries(api)) {
if (typeof value === 'function') {
+13
View File
@@ -319,6 +319,7 @@ export interface InvalidResponse {
type ExtractValid<T> = T extends ValidResponse ? T : never;
type ExtractInvalid<T> = T extends InvalidResponse ? T : never;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Callable = (...args: any) => any;
export type ExtractResponse<T extends Callable> = ExtractValid<Awaited<ReturnType<T>>>;
@@ -327,17 +328,29 @@ export type ExtractQuery<T extends Callable> = Parameters<T>[0];
export type DefAPINamespace = {
[key: string]: DefAPINamespace
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| BasicGetAPICallT<any, any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| BasicPostAPICallT<any, any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| BasicPutAPICallT<any, any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| BasicDeleteAPICallT<any, any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| BasicPatchAPICallT<any, any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| BasicHeadAPICallT<any, any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| EmptyGetAPICallT<any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| EmptyPostAPICallT<any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| EmptyPutAPICallT<any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| EmptyDeleteAPICallT<any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| EmptyPatchAPICallT<any, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| EmptyHeadAPICallT<any, any>
;
}