question: defaultMetadataStorage is no more available in 0.3.2

Author: Arnaud-Dev-NodejsCreated Jan 19, 2021Updated Aug 25, 2025
Labelstype: question

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

typescript

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."

Source: typestack/class-transformer