refactor: improve signature of l10n-translate-pipe for better type inference#351
Merged
robisim74 merged 1 commit intorobisim74:masterfrom Apr 16, 2025
Merged
Conversation
…ference In applications using "strictTemplates" angular compiler option, the signature of the translate pipe is problematic: Regardless of the passed key, the return type always includes `null`. In reality however, unless `null` or an empty string is passed, the pipe actually always returns a string. This adds some overload signatures to align with the pipes actual behaviour.
Owner
|
@pweyrich Thanks for this update! |
pweyrich
added a commit
to pweyrich/angular-l10n
that referenced
this pull request
Jun 16, 2025
In my previous change (robisim74#351) I missed the fallback overload that matches the function signature. This introduces new type errors when upgrading to v17.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In applications using "strictTemplates" angular compiler option, the signature of the translate pipe is problematic: Regardless of the passed key, the return type always includes
null. In reality however, unlessnullor an empty string is passed, the pipe actually always returns a string.Example:

This adds some overload signatures to align with the pipes actual behaviour.