diff --git a/libs/plugin/src/generators/convert-signal-inputs/__snapshots__/generator.spec.ts.snap b/libs/plugin/src/generators/convert-signal-inputs/__snapshots__/generator.spec.ts.snap index 769f0d08..5c2793b1 100644 --- a/libs/plugin/src/generators/convert-signal-inputs/__snapshots__/generator.spec.ts.snap +++ b/libs/plugin/src/generators/convert-signal-inputs/__snapshots__/generator.spec.ts.snap @@ -79,10 +79,12 @@ export class MyCmp { withDefaultAlias = input(123, { alias: 'defaultAlias' }); withoutDefaultAlias = input(undefined, { alias: 'noDefaultAlias' }); justAStringAlias = input('', { alias: 'stringAlias' }); - withTransform = input(booleanAttribute(false), { transform: booleanAttribute }); + withTransform = input(booleanAttribute(false), { transform: booleanAttribute }); requiredInput = input.required(); requiredWithAlias = input.required({ alias: 'requiredAlias' }); - requiredWithAliasAndTransform = input.required({ alias: 'transformedRequiredAlias', transform: numberAttribute }); + requiredWithAliasAndTransform = input.required({ alias: 'transformedRequiredAlias', transform: numberAttribute }); + withTransformWithoutType = input(booleanAttribute(false), { transform: booleanAttribute }); + requiredWithTransformWithoutType = input(numberAttribute(1), { transform: numberAttribute }); @Input() set leaveMeAlone(value: number) { console.log('setter', value); @@ -312,13 +314,15 @@ export class MyCmp { withDefaultAlias = input(123, { alias: 'defaultAlias' }); withoutDefaultAlias = input(undefined, { alias: 'noDefaultAlias' }); justAStringAlias = input('', { alias: 'stringAlias' }); - withTransform = input(booleanAttribute(false), { transform: booleanAttribute }); + withTransform = input(booleanAttribute(false), { transform: booleanAttribute }); requiredInput = input.required(); requiredWithAlias = input.required({ alias: 'requiredAlias' }); /* * @description I go with requiredWithAliasAndTransform */ - requiredWithAliasAndTransform = input.required({ alias: 'transformedRequiredAlias', transform: numberAttribute }); + requiredWithAliasAndTransform = input.required({ alias: 'transformedRequiredAlias', transform: numberAttribute }); + withTransformWithoutType = input(booleanAttribute(false), { transform: booleanAttribute }); + requiredWithTransformWithoutType = input(numberAttribute(1), { transform: numberAttribute }); @Input() set leaveMeAlone(value: number) { console.log('setter', value); diff --git a/libs/plugin/src/generators/convert-signal-inputs/generator.spec.ts b/libs/plugin/src/generators/convert-signal-inputs/generator.spec.ts index 8bd59772..da032ef1 100644 --- a/libs/plugin/src/generators/convert-signal-inputs/generator.spec.ts +++ b/libs/plugin/src/generators/convert-signal-inputs/generator.spec.ts @@ -104,10 +104,12 @@ export class MyCmp { @Input({ alias: 'defaultAlias' }) withDefaultAlias = 123; @Input({ alias: 'noDefaultAlias'}) withoutDefaultAlias?: number; @Input('stringAlias') justAStringAlias = ''; - @Input({ transform: booleanAttribute }) withTransform: string | '' = false; + @Input({ transform: booleanAttribute }) withTransform: boolean = false; @Input({ required: true }) requiredInput!: string; @Input({ required: true, alias: 'requiredAlias' }) requiredWithAlias!: boolean; - @Input({ required: true, alias: 'transformedRequiredAlias', transform: numberAttribute }) requiredWithAliasAndTransform!: string | ''; + @Input({ required: true, alias: 'transformedRequiredAlias', transform: numberAttribute }) requiredWithAliasAndTransform!: number; + @Input({ transform: booleanAttribute }) withTransformWithoutType = false; + @Input({ transform: numberAttribute }) requiredWithTransformWithoutType = 1; @Input() set leaveMeAlone(value: number) { console.log('setter', value); @@ -145,13 +147,15 @@ export class MyCmp { @Input({ alias: 'defaultAlias' }) withDefaultAlias = 123; @Input({ alias: 'noDefaultAlias'}) withoutDefaultAlias?: number; @Input('stringAlias') justAStringAlias = ''; - @Input({ transform: booleanAttribute }) withTransform: string | '' = false; + @Input({ transform: booleanAttribute }) withTransform: boolean = false; @Input({ required: true }) requiredInput!: string; @Input({ required: true, alias: 'requiredAlias' }) requiredWithAlias!: boolean; /* * @description I go with requiredWithAliasAndTransform */ - @Input({ required: true, alias: 'transformedRequiredAlias', transform: numberAttribute }) requiredWithAliasAndTransform!: string | ''; + @Input({ required: true, alias: 'transformedRequiredAlias', transform: numberAttribute }) requiredWithAliasAndTransform!: number; + @Input({ transform: booleanAttribute }) withTransformWithoutType = false; + @Input({ transform: numberAttribute }) requiredWithTransformWithoutType = 1; @Input() set leaveMeAlone(value: number) { console.log('setter', value); diff --git a/libs/plugin/src/generators/convert-signal-inputs/generator.ts b/libs/plugin/src/generators/convert-signal-inputs/generator.ts index 0864b380..662a86fd 100644 --- a/libs/plugin/src/generators/convert-signal-inputs/generator.ts +++ b/libs/plugin/src/generators/convert-signal-inputs/generator.ts @@ -92,6 +92,10 @@ function getSignalInputInitializer( } } + if (transformType) { + types.push('| string'); + } + writer.write(types.concat('>').join('')); }