diff --git a/lib/plugin/utils/ast-utils.ts b/lib/plugin/utils/ast-utils.ts index 2078a1d21..162be3653 100644 --- a/lib/plugin/utils/ast-utils.ts +++ b/lib/plugin/utils/ast-utils.ts @@ -46,6 +46,10 @@ export function isStringLiteral(type: Type) { return hasFlag(type, TypeFlags.StringLiteral) && !type.isUnion(); } +export function isStringMapping(type: Type) { + return hasFlag(type, TypeFlags.StringMapping); +} + export function isNumber(type: Type) { return hasFlag(type, TypeFlags.Number); } diff --git a/lib/plugin/utils/plugin-utils.ts b/lib/plugin/utils/plugin-utils.ts index 3608931f3..138a7f85e 100644 --- a/lib/plugin/utils/plugin-utils.ts +++ b/lib/plugin/utils/plugin-utils.ts @@ -13,7 +13,8 @@ import { isInterface, isNumber, isString, - isStringLiteral + isStringLiteral, + isStringMapping } from './ast-utils'; export function getDecoratorOrUndefinedByNames( @@ -65,7 +66,7 @@ export function getTypeReferenceAsString( if (isBigInt(type)) { return { typeName: BigInt.name, arrayDepth }; } - if (isString(type) || isStringLiteral(type)) { + if (isString(type) || isStringLiteral(type) || isStringMapping(type)) { return { typeName: String.name, arrayDepth }; } if (isPromiseOrObservable(getText(type, typeChecker))) { diff --git a/test/plugin/fixtures/project/cats/classes/cat.class.ts b/test/plugin/fixtures/project/cats/classes/cat.class.ts index a70189ebd..7a875ab49 100644 --- a/test/plugin/fixtures/project/cats/classes/cat.class.ts +++ b/test/plugin/fixtures/project/cats/classes/cat.class.ts @@ -25,4 +25,12 @@ export class Cat { enum: LettersEnum; enumArr: LettersEnum; + + uppercaseString: Uppercase; + + lowercaseString: Lowercase; + + capitalizeString: Capitalize; + + uncapitalizeString: Uncapitalize; } diff --git a/test/plugin/fixtures/serialized-meta.fixture.ts b/test/plugin/fixtures/serialized-meta.fixture.ts index b87554c35..9bd46decf 100644 --- a/test/plugin/fixtures/serialized-meta.fixture.ts +++ b/test/plugin/fixtures/serialized-meta.fixture.ts @@ -64,7 +64,11 @@ export default async () => { enumArr: { required: true, enum: t['./cats/dto/pagination-query.dto'].LettersEnum - } + }, + uppercaseString: { required: true, type: () => String }, + lowercaseString: { required: true, type: () => String }, + capitalizeString: { required: true, type: () => String }, + uncapitalizeString: { required: true, type: () => String } } } ],