refactor(transloco): 💡 Allow DeepPartial for test module config
This allows developers using the TranslocoTestingModule to pass other options for missingHandler without duplicating the logMissingKey config already provided
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/jsverse/transloco/blob/master/CONTRIBUTING.md#commit
- [X] 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?
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [x] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:
What is the current behavior?
If you try to pass { allowEmpty: true } as the missingHandler configuration for the testing module you will get the below typescript error, which requires developers to pass all properties of the missingHandler object. This type definition differs from older versions of transloco which only required a partial missingHandler object: https://github.com/jsverse/transloco/blob/transloco-3.2.0/libs/transloco/src/lib/transloco.config.ts#L14
Type '{ allowEmpty: true; }' is missing the following properties from type '{ logMissingKey: boolean; useFallbackTranslation: boolean; allowEmpty: boolean; }': logMissingKey, useFallbackTranslationts(2739)
transloco.config.ts(15, 3): The expected type comes from property 'missingHandler' which is declared here on type 'Partial<TranslocoConfig>'
What is the new behavior?
You can now pass a DeepPartial of the transloco configuration to the TranslocoTestingModule and default values will be applied by the library, which is consistent with the developer experience in the library API.
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No
Other information
@jsverse/transloco
npm i https://pkg.pr.new/@jsverse/transloco@865
@jsverse/transloco-locale
npm i https://pkg.pr.new/@jsverse/transloco-locale@865
@jsverse/transloco-messageformat
npm i https://pkg.pr.new/@jsverse/transloco-messageformat@865
@jsverse/transloco-optimize
npm i https://pkg.pr.new/@jsverse/transloco-optimize@865
@jsverse/transloco-persist-lang
npm i https://pkg.pr.new/@jsverse/transloco-persist-lang@865
@jsverse/transloco-persist-translations
npm i https://pkg.pr.new/@jsverse/transloco-persist-translations@865
@jsverse/transloco-preload-langs
npm i https://pkg.pr.new/@jsverse/transloco-preload-langs@865
@jsverse/transloco-scoped-libs
npm i https://pkg.pr.new/@jsverse/transloco-scoped-libs@865
@jsverse/transloco-utils
npm i https://pkg.pr.new/@jsverse/transloco-utils@865
@jsverse/transloco-validator
npm i https://pkg.pr.new/@jsverse/transloco-validator@865
commit: 6728ce4