Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression on components with inputs using a transform function #483

Closed
mlz11 opened this issue Aug 13, 2024 · 2 comments · Fixed by #484
Closed

Regression on components with inputs using a transform function #483

mlz11 opened this issue Aug 13, 2024 · 2 comments · Fixed by #484

Comments

@mlz11
Copy link
Contributor

mlz11 commented Aug 13, 2024

Hello 👋🏻,

I believe I encountered a regression after bumping the package @testing-library/angular from v17.1.0 to v17.2.1 while trying to use the new inputs property.

The issue arises with components that have inputs using a transform function that changes the type, such as:

 title = input.required<TitleObject, string>({
    transform: toTitleObject,
  });

Below is the test I wrote :

it('should render', async () => {
    await render(ChildComponent, {
      inputs: {
        title: 'title',
      },
    });
  });

In this case, TypeScript raises an error on the render function 🔴:

Type 'typeof ChildComponent' is not assignable to type 'string'.

When modifying the input so that it has the same type as after the transformation, the TypeScript error is resolved, and the test passes 🟢:

it('should render', async () => {
    await render(ChildComponent, {
      inputs: {
        title: {title: 'title'},
      },
    });
  });

Please find a reproduction sample below:

https://github.com/mlz11/atl-issue-pr-473

If this is confirmed as a bug, I would love to contribute to resolving it.

Thanks for your help!

@timdeschryver
Copy link
Member

@mlz11 it seems like this is a valid bug , thanks for opening the issue with a good reproduction!😀
Feel free to open a PR to resolve this issue.

@mlz11
Copy link
Contributor Author

mlz11 commented Aug 13, 2024

@timdeschryver thanks for your quick confirmation.

#484 contains a resolution proposal !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants