Skip to content

Commit 41297bc

Browse files
authored
Merge pull request #1675 from chappelo/refactor/ban-types
refactor/remove @typescript-eslint/ban-types
2 parents 9fd40e4 + 77f0dbc commit 41297bc

File tree

19 files changed

+47
-50
lines changed

19 files changed

+47
-50
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = {
1818
default: 'array-simple',
1919
},
2020
],
21-
'@typescript-eslint/ban-types': 'off',
2221
'@typescript-eslint/naming-convention': [
2322
'error',
2423
{

packages/runtime/src/decorators/customAttribute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function CustomAttribute(_name: string, _value: string): Function {
1+
export function CustomAttribute(_name: string, _value: string): PropertyDecorator {
22
return () => {
33
return;
44
};

packages/runtime/src/decorators/deprecated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* used to show a method as deprecated on swagger documentation
33
*/
4-
export function Deprecated(): Function {
4+
export function Deprecated(): PropertyDecorator & ClassDecorator & ParameterDecorator {
55
return () => {
66
return;
77
};

packages/runtime/src/decorators/example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function Example<T>(exampleModel: T, exampleLabel?: string): Function {
1+
export function Example<T>(exampleModel: T, exampleLabel?: string): PropertyDecorator {
22
return () => {
33
return;
44
};

packages/runtime/src/decorators/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function Extension(_name: string, _value: ExtensionType | ExtensionType[]): Function {
1+
export function Extension(_name: string, _value: ExtensionType | ExtensionType[]): PropertyDecorator {
22
return () => {
33
return;
44
};

packages/runtime/src/decorators/methods.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
export function Options(value?: string): Function {
1+
export function Options(value?: string): MethodDecorator {
22
return () => {
33
return;
44
};
55
}
66

7-
export function Get(value?: string): Function {
7+
export function Get(value?: string): MethodDecorator {
88
return () => {
99
return;
1010
};
1111
}
1212

13-
export function Post(value?: string): Function {
13+
export function Post(value?: string): MethodDecorator {
1414
return () => {
1515
return;
1616
};
1717
}
1818

19-
export function Put(value?: string): Function {
19+
export function Put(value?: string): MethodDecorator {
2020
return () => {
2121
return;
2222
};
2323
}
2424

25-
export function Patch(value?: string): Function {
25+
export function Patch(value?: string): MethodDecorator {
2626
return () => {
2727
return;
2828
};
2929
}
3030

31-
export function Delete(value?: string): Function {
31+
export function Delete(value?: string): MethodDecorator {
3232
return () => {
3333
return;
3434
};
3535
}
3636

37-
export function Head(value?: string): Function {
37+
export function Head(value?: string): MethodDecorator {
3838
return () => {
3939
return;
4040
};

packages/runtime/src/decorators/middlewares.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
2-
/* eslint-disable @typescript-eslint/no-explicit-any */
3-
type Middleware<T extends Function | Object> = T;
1+
type Middleware<T extends CallableFunction | object> = T;
42

53
const TSOA_MIDDLEWARES = Symbol('@tsoa:middlewares');
64

@@ -34,7 +32,7 @@ function decorator(fn: (value: any) => void) {
3432
* @param middlewares
3533
* @returns
3634
*/
37-
export function Middlewares<T extends Function | Object>(...mws: Array<Middleware<T>>): ClassDecorator & MethodDecorator {
35+
export function Middlewares<T extends CallableFunction | object>(...mws: Array<Middleware<T>>): ClassDecorator & MethodDecorator {
3836
return decorator(target => {
3937
if (mws) {
4038
const current = fetchMiddlewares<T>(target);
@@ -49,6 +47,6 @@ export function Middlewares<T extends Function | Object>(...mws: Array<Middlewar
4947
* @param target
5048
* @returns list of middlewares
5149
*/
52-
export function fetchMiddlewares<T extends Function | Object>(target: any): Array<Middleware<T>> {
50+
export function fetchMiddlewares<T extends CallableFunction | object>(target: any): Array<Middleware<T>> {
5351
return Reflect.getMetadata(TSOA_MIDDLEWARES, target) || [];
5452
}

packages/runtime/src/decorators/operationid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function OperationId(value: string): Function {
1+
export function OperationId(value: string): MethodDecorator {
22
return () => {
33
return;
44
};

packages/runtime/src/decorators/parameter.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Inject http Body
33
* @param {string} [name] properties name in body object
44
*/
5-
export function Body(): Function {
5+
export function Body(): ParameterDecorator {
66
return () => {
77
return;
88
};
@@ -13,7 +13,7 @@ export function Body(): Function {
1313
*
1414
* @param {string} [name] The name of the body parameter
1515
*/
16-
export function BodyProp(name?: string): Function {
16+
export function BodyProp(name?: string): ParameterDecorator {
1717
return () => {
1818
return;
1919
};
@@ -22,7 +22,7 @@ export function BodyProp(name?: string): Function {
2222
/**
2323
* Inject http request
2424
*/
25-
export function Request(): Function {
25+
export function Request(): ParameterDecorator {
2626
return () => {
2727
return;
2828
};
@@ -33,7 +33,7 @@ export function Request(): Function {
3333
*
3434
* @param {name} [name] The name of the request parameter
3535
*/
36-
export function RequestProp(name?: string): Function {
36+
export function RequestProp(name?: string): ParameterDecorator {
3737
return () => {
3838
return;
3939
};
@@ -44,7 +44,7 @@ export function RequestProp(name?: string): Function {
4444
*
4545
* @param {string} [name] The name of the path parameter
4646
*/
47-
export function Path(name?: string): Function {
47+
export function Path(name?: string): ParameterDecorator {
4848
return () => {
4949
return;
5050
};
@@ -55,7 +55,7 @@ export function Path(name?: string): Function {
5555
*
5656
* @param {string} [name] The name of the query parameter
5757
*/
58-
export function Query(name?: string): Function {
58+
export function Query(name?: string): ParameterDecorator {
5959
return () => {
6060
return;
6161
};
@@ -64,7 +64,7 @@ export function Query(name?: string): Function {
6464
/**
6565
* Inject all query values in a single object
6666
*/
67-
export function Queries(): Function {
67+
export function Queries(): ParameterDecorator {
6868
return () => {
6969
return;
7070
};
@@ -75,7 +75,7 @@ export function Queries(): Function {
7575
*
7676
* @param {string} [name] The name of the header parameter
7777
*/
78-
export function Header(name?: string): Function {
78+
export function Header(name?: string): ParameterDecorator {
7979
return () => {
8080
return;
8181
};
@@ -84,7 +84,7 @@ export function Header(name?: string): Function {
8484
/**
8585
* Mark parameter as manually injected, which will not be generated
8686
*/
87-
export function Inject(): Function {
87+
export function Inject(): ParameterDecorator {
8888
return () => {
8989
return;
9090
};
@@ -95,7 +95,7 @@ export function Inject(): Function {
9595
*
9696
* @param {string} [name] The name of the uploaded file parameter
9797
*/
98-
export function UploadedFile(name?: string): Function {
98+
export function UploadedFile(name?: string): ParameterDecorator {
9999
return () => {
100100
return;
101101
};
@@ -106,7 +106,7 @@ export function UploadedFile(name?: string): Function {
106106
*
107107
* @param {string} [name] The name of the uploaded files parameter
108108
*/
109-
export function UploadedFiles(name?: string): Function {
109+
export function UploadedFiles(name?: string): ParameterDecorator {
110110
return () => {
111111
return;
112112
};
@@ -117,7 +117,7 @@ export function UploadedFiles(name?: string): Function {
117117
*
118118
* @param {string} [name] The name of the uploaded files parameter
119119
*/
120-
export function FormField(name?: string): Function {
120+
export function FormField(name?: string): ParameterDecorator {
121121
return () => {
122122
return;
123123
};
@@ -130,7 +130,7 @@ export function FormField(name?: string): Function {
130130
*
131131
* @link https://swagger.io/docs/specification/describing-request-body/
132132
*/
133-
export function Consumes(value: string): Function {
133+
export function Consumes(value: string): MethodDecorator {
134134
return () => {
135135
return;
136136
};

packages/runtime/src/decorators/response.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { IsValidHeader } from '../utils/isHeaderType';
22
import { HttpStatusCodeLiteral, HttpStatusCodeStringLiteral, OtherValidOpenApiHttpStatusCode } from '../interfaces/response';
33

4-
export function SuccessResponse<HeaderType extends IsValidHeader<HeaderType> = {}>(name: string | number, description?: string, produces?: string | string[]): Function {
4+
export function SuccessResponse<HeaderType extends IsValidHeader<HeaderType> = object>(name: string | number, description?: string, produces?: string | string[]): MethodDecorator {
55
return () => {
66
return;
77
};
88
}
99

10-
export function Response<ExampleType, HeaderType extends IsValidHeader<HeaderType> = {}>(
10+
export function Response<ExampleType, HeaderType extends IsValidHeader<HeaderType> = object>(
1111
name: HttpStatusCodeLiteral | HttpStatusCodeStringLiteral | OtherValidOpenApiHttpStatusCode,
1212
description?: string,
1313
example?: ExampleType,
1414
produces?: string | string[],
15-
): Function {
15+
): MethodDecorator & ClassDecorator {
1616
return () => {
1717
return;
1818
};
@@ -23,7 +23,7 @@ export function Response<ExampleType, HeaderType extends IsValidHeader<HeaderTyp
2323
*
2424
* The type of the responder function should be annotated `TsoaResponse<Status, Data, Headers>` in order to support OpenAPI documentation.
2525
*/
26-
export function Res(): Function {
26+
export function Res(): ParameterDecorator {
2727
return () => {
2828
return;
2929
};
@@ -35,7 +35,7 @@ export function Res(): Function {
3535
*
3636
* @link https://swagger.io/docs/specification/media-types/
3737
*/
38-
export function Produces(value: string): Function {
38+
export function Produces(value: string): MethodDecorator & ClassDecorator {
3939
return () => {
4040
return;
4141
};

0 commit comments

Comments
 (0)