Skip to content

refactor: improve signature of l10n-translate-pipe for better type inference#351

Merged
robisim74 merged 1 commit intorobisim74:masterfrom
pweyrich:translate-pipe-signature
Apr 16, 2025
Merged

refactor: improve signature of l10n-translate-pipe for better type inference#351
robisim74 merged 1 commit intorobisim74:masterfrom
pweyrich:translate-pipe-signature

Conversation

@pweyrich
Copy link
Contributor

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.

Example:
Screenshot 2025-04-14 at 12 28 16

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

…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.
@robisim74 robisim74 merged commit b35865c into robisim74:master Apr 16, 2025
1 check passed
@robisim74
Copy link
Owner

@pweyrich Thanks for this update!

@pweyrich pweyrich deleted the translate-pipe-signature branch April 16, 2025 08:27
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.
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.

2 participants