Skip to content

Commit 830abe4

Browse files
committed
eliminated any in safe places
1 parent a25be82 commit 830abe4

14 files changed

+32
-29
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@typescript-eslint/interface-name-prefix": "off",
2727
"@typescript-eslint/explicit-function-return-type": "off",
2828
"@typescript-eslint/explicit-module-boundary-types": "off",
29-
"@typescript-eslint/no-explicit-any": "off",
29+
"@typescript-eslint/no-explicit-any": "warn",
3030
"@typescript-eslint/no-use-before-define": "warn",
3131
"@typescript-eslint/no-unused-vars": [
3232
"error", {

lib/interface/asyncapi-common.interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export interface OAuthFlowObject {
156156
scopes: ScopesObject;
157157
}
158158

159-
export type ScopesObject = Record<string, any>;
159+
export type ScopesObject = Record<string, unknown>;
160160

161161
export type ParameterObject = BaseParameterObject;
162162

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface AsyncApiOperationHeaders {
22
[key: string]: {
33
description: string;
4-
[key: string]: any;
4+
[key: string]: unknown;
55
};
66
}

lib/interface/asyncapi-operation-options-raw.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface RawAsyncApiMessage {
1212
[key: string]: {
1313
description: string;
1414
type: 'string';
15-
[key: string]: any;
15+
[key: string]: unknown;
1616
};
1717
};
1818
};

lib/interface/generator-options.interface.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AsyncApiDocument } from './asyncapi-common.interfaces';
12
import { AsyncApiTemplateOptions } from './asyncapi-template-options.interface';
23

34
export interface GeneratorOptions {
@@ -10,11 +11,11 @@ export interface GeneratorOptions {
1011
forceWrite: boolean;
1112
debug: boolean;
1213
install: boolean;
13-
templateConfig: Record<string, any>;
14-
hooks: Record<string, any>;
14+
templateConfig: Record<string, unknown>;
15+
hooks: Record<string, unknown>;
1516
templateParams: AsyncApiTemplateOptions;
16-
generate: (document: any) => Promise<void>;
17+
generate: (document: AsyncApiDocument) => Promise<void>;
1718
generateFromURL: (url: string) => Promise<void>;
1819
generateFromFile: (path: string) => Promise<void>;
19-
generateFromString: (yaml: string, args?: any) => Promise<string>;
20+
generateFromString: (yaml: string, args?: unknown) => Promise<string>;
2021
}

lib/services/asyncapi.explorer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class AsyncApiExplorer {
2121
controllerKey ? `${controllerKey}_${methodKey}` : methodKey;
2222

2323
public explorerAsyncapiServices(
24-
wrapper: InstanceWrapper<any>,
24+
wrapper: InstanceWrapper,
2525
modulePath?: string,
2626
globalPrefix?: string,
2727
operationIdFactory?: (controllerKey: string, methodKey: string) => string,
@@ -77,7 +77,7 @@ export class AsyncApiExplorer {
7777
_globalPrefix?: string,
7878
): DenormalizedDoc[] {
7979
const denormalizedAsyncapiServices = this.metadataScanner.scanFromPrototype<
80-
any,
80+
unknown,
8181
DenormalizedDoc[]
8282
>(instance, prototype, (name) => {
8383
const targetCallback = prototype[name];

lib/services/asyncapi.generator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import Generator from '@asyncapi/generator';
22
import jsyaml from 'js-yaml';
33
import os from 'os';
4-
import { AsyncApiTemplateOptions, GeneratorOptions } from '../interface';
4+
import {
5+
AsyncApiDocument,
6+
AsyncApiTemplateOptions,
7+
GeneratorOptions,
8+
} from '../interface';
59

610
export class AsyncapiGenerator {
711
private readonly generator: GeneratorOptions;
@@ -18,7 +22,7 @@ export class AsyncapiGenerator {
1822
});
1923
}
2024

21-
public async generate(contract: any): Promise<string> {
25+
public async generate(contract: AsyncApiDocument): Promise<string> {
2226
const yaml = jsyaml.dump(contract);
2327
return await this.generator.generateFromString(yaml, {
2428
resolve: {

sample/felines/class/feline.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export abstract class Feline {
2323

2424
birthDatetime: Date;
2525

26-
constructor(initializer: Record<string, any>) {
26+
constructor(initializer: Record<string, unknown>) {
2727
Object.assign(this, initializer);
2828
}
2929
}

sample/felines/class/message.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export abstract class Message<T extends Record<string, any>> {
1111

1212
abstract payload: T;
1313

14-
constructor(partialData: Record<string, any>) {
14+
constructor(partialData: Partial<Message<T>>) {
1515
Object.assign(this, partialData);
1616
}
1717
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { ApiProperty, getSchemaPath } from '@nestjs/swagger';
2-
import { Cat, Lion, Message, Tiger } from '../class';
2+
import { Cat, Feline, Lion, Message, Tiger } from '../class';
33

4-
type AllFelines = Cat | Lion | Tiger;
5-
6-
export class CreateFelineDto extends Message<AllFelines> {
4+
export class CreateFelineDto extends Message<Feline> {
75
@ApiProperty({
86
oneOf: [
97
{ $ref: getSchemaPath(Cat) },
108
{ $ref: getSchemaPath(Lion) },
119
{ $ref: getSchemaPath(Tiger) },
1210
],
1311
})
14-
payload: Cat | Lion | Tiger;
12+
payload: Feline;
1513
}

0 commit comments

Comments
 (0)