Skip to content

Commit 085d8bd

Browse files
committed
remove @typescript-eslint/no-unsafe-call
1 parent e10185b commit 085d8bd

File tree

20 files changed

+52
-25
lines changed

20 files changed

+52
-25
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module.exports = {
3131
],
3232
'@typescript-eslint/no-explicit-any': 'off',
3333
'@typescript-eslint/no-unsafe-assignment': 'off',
34-
'@typescript-eslint/no-unsafe-call': 'off',
3534
'@typescript-eslint/no-unsafe-argument': 'off',
3635
'@typescript-eslint/no-unsafe-member-access': 'off',
3736
'@typescript-eslint/no-unsafe-return': 'off',

packages/cli/src/cli.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,12 @@ export async function generateSpecAndRoutes(args: SwaggerArgs, metadata?: Tsoa.M
397397
throw err;
398398
}
399399
}
400+
401+
export type RouteGeneratorModule<Config extends ExtendedRoutesConfig> = {
402+
default: new (
403+
metadata: Tsoa.Metadata,
404+
routesConfig: Config,
405+
) => {
406+
GenerateCustomRoutes: () => Promise<void>;
407+
};
408+
};

packages/cli/src/module/generate-routes.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as ts from 'typescript';
2-
import { ExtendedRoutesConfig } from '../cli';
2+
import { ExtendedRoutesConfig, RouteGeneratorModule } from '../cli';
33
import { MetadataGenerator } from '../metadataGeneration/metadataGenerator';
44
import { Tsoa } from '@tsoa/runtime';
55
import { DefaultRouteGenerator } from '../routeGeneration/defaultRouteGenerator';
@@ -46,12 +46,13 @@ async function getRouteGenerator<Config extends ExtendedRoutesConfig>(metadata:
4646
if (typeof routeGenerator === 'string') {
4747
try {
4848
// try as a module import
49-
const module = await import(routeGenerator);
49+
const module = (await import(routeGenerator)) as RouteGeneratorModule<Config>;
50+
5051
return new module.default(metadata, routesConfig);
5152
} catch (_err) {
5253
// try to find a relative import path
5354
const relativePath = path.relative(__dirname, routeGenerator);
54-
const module = await import(relativePath);
55+
const module = (await import(relativePath)) as RouteGeneratorModule<Config>;
5556
return new module.default(metadata, routesConfig);
5657
}
5758
} else {

packages/cli/src/swagger/specGenerator2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ export class SpecGenerator2 extends SpecGenerator {
6868

6969
if (this.config.spec) {
7070
this.config.specMerging = this.config.specMerging || 'immediate';
71-
const mergeFuncs: { [key: string]: any } = {
71+
const mergeFuncs: { [key: string]: (spec: UnspecifiedObject, merge: UnspecifiedObject) => UnspecifiedObject } = {
7272
immediate: Object.assign,
7373
recursive: mergeAnything,
7474
deepmerge: (spec: UnspecifiedObject, merge: UnspecifiedObject): UnspecifiedObject => deepMerge(spec, merge),
7575
};
7676

77-
spec = mergeFuncs[this.config.specMerging](spec, this.config.spec);
77+
spec = mergeFuncs[this.config.specMerging](spec as unknown as UnspecifiedObject, this.config.spec as unknown as UnspecifiedObject) as unknown as Swagger.Spec2;
7878
}
7979
if (this.config.schemes) {
8080
spec.schemes = this.config.schemes;

packages/cli/src/swagger/specGenerator3.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ export class SpecGenerator3 extends SpecGenerator {
3939

4040
if (this.config.spec) {
4141
this.config.specMerging = this.config.specMerging || 'immediate';
42-
const mergeFuncs: { [key: string]: any } = {
42+
const mergeFuncs: { [key: string]: (spec: UnspecifiedObject, merge: UnspecifiedObject) => UnspecifiedObject } = {
4343
immediate: Object.assign,
4444
recursive: mergeAnything,
4545
deepmerge: (spec: UnspecifiedObject, merge: UnspecifiedObject): UnspecifiedObject => deepMerge(spec, merge),
4646
};
4747

48-
spec = mergeFuncs[this.config.specMerging](spec, this.config.spec);
48+
spec = mergeFuncs[this.config.specMerging](spec as unknown as UnspecifiedObject, this.config.spec as UnspecifiedObject) as unknown as Swagger.Spec3;
4949
}
5050

5151
return spec;

packages/runtime/src/routeGeneration/templates/express/expressTemplateService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FieldErrors } from '../../templateHelpers';
55
import { TsoaRoute } from '../../tsoa-route';
66
import { ValidateError } from '../../templateHelpers';
77
import { TemplateService } from '../templateService';
8+
import { Readable } from 'node:stream';
89

910
type ExpressApiHandlerParameters = {
1011
methodName: string;
@@ -115,7 +116,7 @@ export class ExpressTemplateService extends TemplateService<ExpressApiHandlerPar
115116
});
116117
if (data && typeof data.pipe === 'function' && data.readable && typeof data._read === 'function') {
117118
response.status(statusCode || 200);
118-
data.pipe(response);
119+
(data as Readable).pipe(response);
119120
} else if (data !== null && data !== undefined) {
120121
response.status(statusCode || 200).json(data);
121122
} else {

packages/runtime/src/routeGeneration/templates/templateService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export abstract class TemplateService<ApiHandlerParameters, ValidationArgsParame
2626
protected buildPromise(methodName: string, controller: Controller | object, validatedArgs: any) {
2727
const prototype = Object.getPrototypeOf(controller);
2828
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
29-
return descriptor!.value.apply(controller, validatedArgs);
29+
30+
return (descriptor!.value as () => Promise<PropertyDescriptor>).apply(controller, validatedArgs);
3031
}
3132
}

tests/esm/fixtures/express/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ app.use(bodyParser.json() as RequestHandler);
1313
app.use((req, res, next) => {
1414
methodOverride()(req, res, next);
1515
});
16-
app.use((req: any, res: any, next: any) => {
16+
app.use((req: any, res: any, next: express.NextFunction) => {
1717
req.stringValue = 'fancyStringForContext';
1818
next();
1919
});

tests/fixtures/custom/custom-route-generator/serverlessRouteGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default class ServerlessRouteGenerator extends AbstractRouteGenerator<Ser
7777
// This would need to generate a CDK "Stack" that takes the tsoa metadata as input and generates a valid serverless CDK infrastructure stack from template
7878
const templateFileName = this.options.stackTemplate;
7979
const fileName = `${this.options.routesDir}/stack.ts`;
80-
const context = this.buildContext() as unknown as any;
80+
const context = this.buildContext();
8181
context.controllers = context.controllers.map(controller => {
8282
controller.actions = controller.actions.map(action => {
8383
return {

tests/fixtures/custom/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ app.use(bodyParser.json());
2323
app.use((req, res, next) => {
2424
methodOverride()(req, res, next);
2525
});
26-
app.use((req: any, res: any, next: any) => {
26+
app.use((req: any, res: any, next: express.NextFunction) => {
2727
req.stringValue = 'fancyStringForContext';
2828
next();
2929
});

0 commit comments

Comments
 (0)