Skip to content

Commit

Permalink
fix(nestjs): make sure mapOptions passed in as null if it's empty
Browse files Browse the repository at this point in the history
fix #247
  • Loading branch information
nartc committed Jan 25, 2021
1 parent 96baeaa commit 93e3761
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/nestjs/src/lib/interceptors/map.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isEmpty } from '@automapper/core';
import type { MapOptions, Mapper } from '@automapper/types';
import type {
CallHandler,
Expand All @@ -22,6 +23,7 @@ function createMapInterceptor(
options?: { isArray?: boolean; mapperName?: string }
): new (...args) => NestInterceptor {
const { isArray = false, mapperName, ...mapOptions } = options || {};
const transformedMapOptions = isEmpty(mapOptions) ? null : mapOptions;

class MixinMapInterceptor implements NestInterceptor {
constructor(
Expand All @@ -47,7 +49,7 @@ function createMapInterceptor(
to as any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
from as any,
mapOptions
transformedMapOptions
);
}

Expand All @@ -57,7 +59,7 @@ function createMapInterceptor(
to as any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
from as any,
mapOptions
transformedMapOptions
);
})
);
Expand Down

0 comments on commit 93e3761

Please sign in to comment.