Skip to content

Commit 85d7384

Browse files
Merge pull request #1155 from jbpionnier/refactor_clean_as_any
refactor(nestjs) code style, clean "as any"
2 parents 3e851e5 + 8a827ff commit 85d7384

20 files changed

+28
-28
lines changed

packages/common/cache/cache.providers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function createCacheManager(): Provider {
1111
const cacheManager = loadPackage('cache-manager', 'CacheModule');
1212
const memoryCache = cacheManager.caching({
1313
...defaultCacheOptions,
14-
...((options || {}) as any),
14+
...(options || {}),
1515
});
1616
return memoryCache;
1717
},

packages/common/decorators/http/create-route-param-metadata.decorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function createParamDecorator(
6363
index,
6464
factory,
6565
paramData,
66-
...((paramPipes as any) as PipeTransform[]),
66+
...(paramPipes as PipeTransform[]),
6767
),
6868
target.constructor,
6969
key,

packages/common/test/cache/cache.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('CacheModule', () => {
88
const options = {
99
test: 'test',
1010
};
11-
const dynamicModule = CacheModule.register(options as any);
11+
const dynamicModule = CacheModule.register(options);
1212

1313
expect(dynamicModule.providers).to.have.length(1);
1414
expect(dynamicModule.imports).to.be.empty;

packages/common/test/pipes/parse-int.pipe.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ describe('ParseIntPipe', () => {
1212
describe('when validation passes', () => {
1313
it('should return number', async () => {
1414
const num = '3';
15-
expect(await target.transform(num, {} as any)).to.equal(
15+
expect(await target.transform(num, {} as ArgumentMetadata)).to.equal(
1616
parseInt(num, 10),
1717
);
1818
});
1919
});
2020
describe('when validation fails', () => {
2121
it('should throw an error', async () => {
22-
return expect(target.transform('123abc', {} as any)).to.be.rejected;
22+
return expect(target.transform('123abc', {} as ArgumentMetadata)).to.be.rejected;
2323
});
2424
});
2525
});

packages/core/adapters/express-adapter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,27 @@ export class ExpressAdapter implements HttpServer {
7676
}
7777

7878
setErrorHandler(handler: Function) {
79-
return this.use(handler as any);
79+
return this.use(handler);
8080
}
8181

8282
setNotFoundHandler(handler: Function) {
83-
return this.use(handler as any);
83+
return this.use(handler);
8484
}
8585

8686
setHeader(response, name: string, value: string) {
8787
return response.set(name, value);
8888
}
8989

9090
getHttpServer<T = any>(): T {
91-
return this.httpServer as any as T;
91+
return this.httpServer as T;
9292
}
9393

9494
setHttpServer(httpServer) {
9595
this.httpServer = httpServer;
9696
}
9797

9898
getInstance<T = any>(): T {
99-
return this.instance as any as T;
99+
return this.instance as T;
100100
}
101101

102102
close() {

packages/core/adapters/fastify-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ export class FastifyAdapter {
8181
}
8282

8383
getHttpServer<T = any>(): T {
84-
return this.instance.server as any as T;
84+
return this.instance.server as T;
8585
}
8686

8787
getInstance<T = any>(): T {
88-
return this.instance as any as T;
88+
return this.instance as T;
8989
}
9090

9191
register(...args) {

packages/core/exceptions/base-exception-filter-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class BaseExceptionFilterContext extends ContextCreator {
5252
if (!module) {
5353
return undefined;
5454
}
55-
return module.injectables.get((filter as any).name);
55+
return module.injectables.get(filter.name);
5656
}
5757

5858
public reflectCatchExceptions(instance: ExceptionFilter): Type<any>[] {

packages/core/exceptions/base-exception-filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
2727
exception.stack,
2828
);
2929
}
30-
return BaseExceptionFilter.logger.error(exception as any);
30+
return BaseExceptionFilter.logger.error(exception);
3131
}
3232
const res = exception.getResponse();
3333
const message = isObject(res)

packages/core/guards/guards-context-creator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class GuardsContextCreator extends ContextCreator {
6060
if (!module) {
6161
return undefined;
6262
}
63-
return module.injectables.get((guard as any).name);
63+
return module.injectables.get(guard.name);
6464
}
6565

6666
public getGlobalMetadata<T extends any[]>(): T {

packages/core/interceptors/interceptors-context-creator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class InterceptorsContextCreator extends ContextCreator {
6565
if (!module) {
6666
return undefined;
6767
}
68-
return module.injectables.get((metatype as any).name);
68+
return module.injectables.get(metatype.name);
6969
}
7070

7171
public getGlobalMetadata<T extends any[]>(): T {

0 commit comments

Comments
 (0)