Skip to content

question: defaultMetadataStorage is no more available in 0.3.2 #563

Open
@Arnaud-Dev-Nodejs

Description

@Arnaud-Dev-Nodejs

Description

In the previous version it was possible to access to the defaultMetadataStorage which was useful to create custom transformer.

for example :
Minimal code-snippet showcasing the problem

import { TransformOptions } from 'class-transformer';
import { defaultMetadataStorage } from 'class-transformer/storage/'; <== cannot find module anymore

export function doSplit(separator: string | RegExp = ' ') {
  return (value: any) => {
    return value !== undefined && value !== null
      ? String(value).split(separator)
      : [];
  };
}
export function Split(
  separator: string | RegExp,
  options: TransformOptions = {},
): PropertyDecorator {
  const transformFn = doSplit(separator);

  return function (target: any, propertyName: string | symbol): void {
    defaultMetadataStorage.addTransformMetadata({
      target: target.constructor,
      propertyName: propertyName as string,
      transformFn,
      options,
    });
  };
}

Expected behavior

Get the defaultMetadataStorage !

Actual behavior

"Cannot find module 'class-transformer/storage' or its corresponding type declarations."

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions