Skip to content

Commit

Permalink
fix: resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Aug 20, 2020
2 parents 565e256 + abcc397 commit f6004a1
Show file tree
Hide file tree
Showing 8 changed files with 2,165 additions and 1,954 deletions.
1 change: 1 addition & 0 deletions lib/index.ts
@@ -1,3 +1,4 @@
export * from './mapped-type.interface';
export * from './intersection-type.helper';
export * from './omit-type.helper';
export * from './partial-type.helper';
Expand Down
5 changes: 3 additions & 2 deletions lib/intersection-type.helper.ts
@@ -1,4 +1,5 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
import {
inheritPropertyInitializers,
inheritTransformationMetadata,
Expand All @@ -8,7 +9,7 @@ import {
export function IntersectionType<A, B>(
classARef: Type<A>,
classBRef: Type<B>,
): Type<A & B> {
): MappedType<A & B> {
abstract class IntersectionClassType {
constructor() {
inheritPropertyInitializers(this, classARef);
Expand All @@ -24,5 +25,5 @@ export function IntersectionType<A, B>(
Object.defineProperty(IntersectionClassType, 'name', {
value: `Intersection${classARef.name}${classBRef.name}`,
});
return IntersectionClassType as Type<A & B>;
return IntersectionClassType as MappedType<A & B>;
}
5 changes: 5 additions & 0 deletions lib/mapped-type.interface.ts
@@ -0,0 +1,5 @@
import { Type } from '@nestjs/common';

export interface MappedType<T> extends Type<T> {
new (): T;
}
5 changes: 3 additions & 2 deletions lib/omit-type.helper.ts
@@ -1,4 +1,5 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
import {
inheritPropertyInitializers,
inheritTransformationMetadata,
Expand All @@ -8,7 +9,7 @@ import {
export function OmitType<T, K extends keyof T>(
classRef: Type<T>,
keys: readonly K[],
): Type<Omit<T, typeof keys[number]>> {
): MappedType<Omit<T, typeof keys[number]>> {
const isInheritedPredicate = (propertyKey: string) =>
!keys.includes(propertyKey as K);

Expand All @@ -21,5 +22,5 @@ export function OmitType<T, K extends keyof T>(
inheritValidationMetadata(classRef, OmitClassType, isInheritedPredicate);
inheritTransformationMetadata(classRef, OmitClassType, isInheritedPredicate);

return OmitClassType as Type<Omit<T, typeof keys[number]>>;
return OmitClassType as MappedType<Omit<T, typeof keys[number]>>;
}
5 changes: 3 additions & 2 deletions lib/partial-type.helper.ts
@@ -1,12 +1,13 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
import {
applyIsOptionalDecorator,
inheritPropertyInitializers,
inheritTransformationMetadata,
inheritValidationMetadata,
} from './type-helpers.utils';

export function PartialType<T>(classRef: Type<T>): Type<Partial<T>> {
export function PartialType<T>(classRef: Type<T>): MappedType<Partial<T>> {
abstract class PartialClassType {
constructor() {
inheritPropertyInitializers(this, classRef);
Expand All @@ -25,5 +26,5 @@ export function PartialType<T>(classRef: Type<T>): Type<Partial<T>> {
Object.defineProperty(PartialClassType, 'name', {
value: `Partial${classRef.name}`,
});
return PartialClassType as Type<Partial<T>>;
return PartialClassType as MappedType<Partial<T>>;
}
5 changes: 3 additions & 2 deletions lib/pick-type.helper.ts
@@ -1,4 +1,5 @@
import { Type } from '@nestjs/common';
import { MappedType } from './mapped-type.interface';
import {
inheritPropertyInitializers,
inheritTransformationMetadata,
Expand All @@ -8,7 +9,7 @@ import {
export function PickType<T, K extends keyof T>(
classRef: Type<T>,
keys: readonly K[],
): Type<Pick<T, typeof keys[number]>> {
): MappedType<Pick<T, typeof keys[number]>> {
const isInheritedPredicate = (propertyKey: string) =>
keys.includes(propertyKey as K);

Expand All @@ -20,5 +21,5 @@ export function PickType<T, K extends keyof T>(
inheritValidationMetadata(classRef, PickClassType, isInheritedPredicate);
inheritTransformationMetadata(classRef, PickClassType, isInheritedPredicate);

return PickClassType as Type<Pick<T, typeof keys[number]>>;
return PickClassType as MappedType<Pick<T, typeof keys[number]>>;
}

0 comments on commit f6004a1

Please sign in to comment.