Skip to content

Commit

Permalink
Added CHANGELOG and README info
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh4 committed Sep 1, 2022
1 parent aa17fb8 commit 7a2f994
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
## 1.1.0

- Added cjs and esm build
- Added missing type exports
- Removed unnecessary transformation and metadata property inheritance for types using real class inheritance
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module but contains some modifications as:
- Use of real inheritance in `PartialType` and `IntersectionType`, as opposed to property only inheritance
- Pass constructor arguments to inherited constructor

> Note: In browser environments the inheritance of `@Exclude` and `@Expose` decorators
> for `Pick-`, `Omit-`, and the second class provided to `IntersectionType` does not work due to
> the following limitation of the `class-transformer` library [issue](https://github.com/typestack/class-transformer/issues/563).
# Usage

The provided type helper classes can be used to create subclasses with altered validation schemas, without the need
Expand Down
2 changes: 0 additions & 2 deletions src/intersection-type.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export function IntersectionType<A, B>(
}
}

inheritValidationMetadata(classARef, IntersectionTypeClass);
inheritTransformationMetadata(classARef, IntersectionTypeClass);
inheritValidationMetadata(classBRef, IntersectionTypeClass);
inheritTransformationMetadata(classBRef, IntersectionTypeClass);

Expand Down
5 changes: 0 additions & 5 deletions src/partial-type.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Type } from "./type.interface";

import {
applyIsOptionalDecorator, getValidationFields,
inheritTransformationMetadata,
inheritValidationMetadata
} from './type-helpers.utils';

/**
Expand All @@ -18,9 +16,6 @@ export function PartialType<T>(classRef: Type<T>): Type<Partial<T>> {
const RefClass = classRef as any;
abstract class PartialTypeClass extends RefClass {}

inheritValidationMetadata(classRef, PartialTypeClass);
inheritTransformationMetadata(classRef, PartialTypeClass);

getValidationFields(classRef).forEach((key) => applyIsOptionalDecorator(PartialTypeClass, key));
return PartialTypeClass as Type<Partial<T>>;
}
6 changes: 0 additions & 6 deletions src/type-helpers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,8 @@ function inheritTransformerMetadata(
isPropertyInherited?: (key: string) => boolean,
) {

/* if(isBrowser()) {
return;
}*/

const classTransformer = require('class-transformer/cjs/storage');

console.log(classTransformer.defaultMetadataStorage);

const metadataStorage /*: typeof import('class-transformer/types/storage').defaultMetadataStorage */ =
classTransformer.defaultMetadataStorage;

Expand Down

0 comments on commit 7a2f994

Please sign in to comment.