Skip to content

Incorrect types generated for @Input with exported transformation function #51672

@uneknown

Description

@uneknown

Which @angular/* package(s) are the source of the bug?

compiler-cli, compiler

Is this a regression?

Yes

Description

When using @Input({transform: transformFn}) and the transformation function is exported from another file, the Angular compiler generates incorrect/mashed up types for the @Input. However, if the transformation function is in the same file as the @Input, everything works as expected. This bug only affects string literal types (I think).

To illustrate the issue, here are screenshots of the incorrect and correct types:

Incorrect types:
Wrong types screenshot

Correct types:
Correct types screenshot

Please provide a link to a minimal reproduction of the bug

https://codesandbox.io/p/github/uneknown/reproduce-angular-transform-issue/master

Please provide the exception or error you saw

None

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16.2.0
Node: 16.17.0
Package Manager: npm 8.15.0
OS: linux x64

Angular: 16.2.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.0
@angular-devkit/build-angular   16.2.0
@angular-devkit/core            16.2.0
@angular-devkit/schematics      16.2.0
@angular/cli                    16.2.0
@schematics/angular             16.2.0
ng-packagr                      16.2.1
rxjs                            7.8.1
typescript                      5.1.6
zone.js                         0.13.1

Anything else?

Steps to Reproduce:

  1. Open CodeSandbox using the link provided above.
  2. Wait until the sandbox has finished booting up, installed all dependencies, and completed the build.
  3. Click on the terminal icon and select "show-output."

At this point, you should be able to view the content of the ...component.d.ts file in the terminal output.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions