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

fix: allow NgAbstractControl as validator param #62

Merged
merged 1 commit into from
Dec 10, 2020
Merged

fix: allow NgAbstractControl as validator param #62

merged 1 commit into from
Dec 10, 2020

Conversation

chrisguttandin
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines: CONTRIBUTING.md#commit
  • [-] Tests for the changes have been added (for bug fixes / features)
  • [-] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The latest version (v1.5) doesn't compile anymore with strict mode enabled.

Issue Number: N/A

What is the new behavior?

It compiles again with the fix.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Please let me know if there is anything I should change.

@itayod
Copy link
Contributor

itayod commented Nov 30, 2020

@chrisguttandin could you explain your use-case?

@chrisguttandin
Copy link
Contributor Author

Hi @itayod, sorry I should have explained it better in the first place. I was the one who already created #26. The problem is that @ngneat/reactive-forms itself doesn't compile anymore when using TypeScript's (or Angular's) --strict flag.

I created a small repo to reproduce the error: https://github.com/chrisguttandin/reactive-forms-demo. Running ng build does currently fail since the control param of the validator functions is not assignable to the control param of the original validator functions.

@itayod
Copy link
Contributor

itayod commented Dec 7, 2020

Hi @chrisguttandin sorry for the delay, I am kind of busy these days...

Haven't look deeply at your problem, it seems like there are 2 ways we can fix this.

  1. to add Angular's AbstractControl to the generic just like you suggested (would be the easier/faster solution, but not the correct one).
  2. create a wrapper to Angular's validator just like we did with the rest of the objects, (this one is the right solution but requires more effort, considering that we will need to update also the schematics and the linter accordingly).

I will take a deeper look at it once I will have the time and let you know what we decide here.

@itayod
Copy link
Contributor

itayod commented Dec 10, 2020

@chrisguttandin thanks for bringing that up, it seems to be caused due to this breaking-changes in typescript 4.

Thanks for taking the time and post this PR, good work 🙏

@itayod itayod merged commit ecc1d6f into ngneat:master Dec 10, 2020
@chrisguttandin chrisguttandin deleted the fix-strict-mode branch December 10, 2020 13:06
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 this pull request may close these issues.

None yet

2 participants