Skip to content

Improve type safety of TranslateService and TranslatePipe#1529

Merged
CodeAndWeb merged 1 commit into
ngx-translate:masterfrom
undsoft:improve-typesafety
May 16, 2025
Merged

Improve type safety of TranslateService and TranslatePipe#1529
CodeAndWeb merged 1 commit into
ngx-translate:masterfrom
undsoft:improve-typesafety

Conversation

@undsoft

@undsoft undsoft commented Mar 7, 2025

Copy link
Copy Markdown
Contributor

Changes

  • TranslatePipe now explicitly accepts null and undefined and returns Translation. The code already guards against falsy values and specifying it explicitly helps when used with strictNullChecks in tsconfig. Otherwise, you may get a bunch of errors when an optional or nullable field is passed to the pipe.
  • Replaced any with unknown in InterpolationParams.
  • Fixes a test on non-English machines.

@Christop406

Copy link
Copy Markdown

Would love this! Makes the pipe much easier to use in strict mode.

@CodeAndWeb CodeAndWeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
I am a fan of stricter checks anyways... :-)

@CodeAndWeb CodeAndWeb merged commit 64305da into ngx-translate:master May 16, 2025
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.

3 participants