Skip to content

Commit

Permalink
correct cycle typestack#358, by extracting TransformationType in a se…
Browse files Browse the repository at this point in the history
…parate file

because:
    * TransformationType enum is used by both TransformOperationExecutor  and MetadataStorage
    * TransformationType was in the same file as TransformOperationExecutor
    * TransformOperationExecutor require MetadataStorage
so: importing TransformationType from TransformOperationExecutor.ts was as a side effect importing MetadataStorage.ts that was importing TransformationType etc. creating a cycle
  • Loading branch information
allan-simon committed Jul 29, 2020
1 parent 056ae01 commit 37bfb12
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/ClassTransformer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ClassTransformOptions} from "./ClassTransformOptions";
import {TransformOperationExecutor, TransformationType} from "./TransformOperationExecutor";
import {TransformOperationExecutor} from "./TransformOperationExecutor";
import { TransformationType} from "./TransformationType";

export type ClassType<T> = {
new (...args: any[]): T;
Expand Down
6 changes: 1 addition & 5 deletions src/TransformOperationExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import { ClassTransformOptions } from "./ClassTransformOptions";
import { defaultMetadataStorage } from "./storage";
import { TypeHelpOptions, TypeOptions } from "./metadata/ExposeExcludeOptions";
import { TypeMetadata } from "./metadata/TypeMetadata";
import { TransformationType } from "./TransformationType";

export enum TransformationType {
PLAIN_TO_CLASS,
CLASS_TO_PLAIN,
CLASS_TO_CLASS
}

export function testForBuffer(): boolean {
try {
Expand Down
5 changes: 5 additions & 0 deletions src/TransformationType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum TransformationType {
PLAIN_TO_CLASS,
CLASS_TO_PLAIN,
CLASS_TO_CLASS
}
2 changes: 1 addition & 1 deletion src/metadata/MetadataStorage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {TypeMetadata} from "./TypeMetadata";
import {ExposeMetadata} from "./ExposeMetadata";
import {ExcludeMetadata} from "./ExcludeMetadata";
import {TransformationType} from "../TransformOperationExecutor";
import {TransformationType} from "../TransformationType";
import {TransformMetadata} from "./TransformMetadata";

/**
Expand Down

0 comments on commit 37bfb12

Please sign in to comment.