refactor(core): use Partial<T> for MetadataOverride (#24103)
Allows to write: const fixture = TestBed .overridePipe(DisplayNamePipe, { set: { pure: false } }) .createComponent(MenuComponent); when you only want to set the `pure` metadata, instead of currently: const fixture = TestBed .overridePipe(DisplayNamePipe, { set: { name: 'displayName', pure: false } }) .createComponent(MenuComponent); which forces you to redefine the name of the pipe even if it is useless. Fixes #24102 PR Close #24103
This commit is contained in:
parent
3fd3c2ac4c
commit
41cd8f3efb
|
@ -2367,9 +2367,9 @@ The [override metadata object](#metadata-override-object) is a generic defined a
|
|||
|
||||
<code-example format="." language="javascript">
|
||||
type MetadataOverride<T> = {
|
||||
add?: T;
|
||||
remove?: T;
|
||||
set?: T;
|
||||
add?: Partial<T>;
|
||||
remove?: Partial<T>;
|
||||
set?: Partial<T>;
|
||||
};
|
||||
</code-example>
|
||||
|
||||
|
@ -2725,9 +2725,9 @@ appropriate to the method, that is, the parameter of an `@NgModule`,
|
|||
|
||||
<code-example format="." language="javascript">
|
||||
type MetadataOverride<T> = {
|
||||
add?: T;
|
||||
remove?: T;
|
||||
set?: T;
|
||||
add?: Partial<T>;
|
||||
remove?: Partial<T>;
|
||||
set?: Partial<T>;
|
||||
};
|
||||
</code-example>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @experimental
|
||||
*/
|
||||
export type MetadataOverride<T> = {
|
||||
add?: T,
|
||||
remove?: T,
|
||||
set?: T
|
||||
add?: Partial<T>,
|
||||
remove?: Partial<T>,
|
||||
set?: Partial<T>
|
||||
};
|
||||
|
|
|
@ -376,7 +376,8 @@ class CompWithUrlTemplate {
|
|||
TestBed
|
||||
.overrideComponent(
|
||||
SomeComponent, {set: {selector: 'comp', template: `{{'hello' | somePipe}}`}})
|
||||
.overridePipe(SomePipe, {set: {name: 'somePipe'}});
|
||||
.overridePipe(SomePipe, {set: {name: 'somePipe'}})
|
||||
.overridePipe(SomePipe, {add: {pure: false}});
|
||||
});
|
||||
it('should work', () => {
|
||||
const compFixture = TestBed.createComponent(SomeComponent);
|
||||
|
|
|
@ -55,9 +55,9 @@ export declare class InjectSetupWrapper {
|
|||
|
||||
/** @experimental */
|
||||
export declare type MetadataOverride<T> = {
|
||||
add?: T;
|
||||
remove?: T;
|
||||
set?: T;
|
||||
add?: Partial<T>;
|
||||
remove?: Partial<T>;
|
||||
set?: Partial<T>;
|
||||
};
|
||||
|
||||
/** @experimental */
|
||||
|
|
Loading…
Reference in New Issue