correct type + test

This commit is contained in:
Niels Lyngsø
2024-03-06 11:35:39 +01:00
parent c118381bb3
commit 25ed8775bc
4 changed files with 9 additions and 8 deletions

View File

@@ -24,8 +24,9 @@ export interface UmbClassInterface extends UmbControllerHost {
? U | undefined
: U
: undefined,
R extends UmbObserverController<SpecificT> = UmbObserverController<SpecificT>,
SpecificR = ObservableType extends undefined ? R | undefined : R,
SpecificR = ObservableType extends undefined
? UmbObserverController<SpecificT> | undefined
: UmbObserverController<SpecificT>,
>(
// This type dance checks if the Observable given could be undefined, if it potentially could be undefined it means that this potentially could return undefined and then call the callback with undefined. [NL]
source: ObservableType,

View File

@@ -47,8 +47,9 @@ export const UmbClassMixin = <T extends ClassConstructor<EventTarget>>(superClas
? U | undefined
: U
: undefined,
R extends UmbObserverController<SpecificT> = UmbObserverController<SpecificT>,
SpecificR = ObservableType extends undefined ? R | undefined : R,
SpecificR = ObservableType extends undefined
? UmbObserverController<SpecificT> | undefined
: UmbObserverController<SpecificT>,
>(
// This type dance checks if the Observable given could be undefined, if it potentially could be undefined it means that this potentially could return undefined and then call the callback with undefined. [NL]
source: ObservableType,

View File

@@ -20,8 +20,9 @@ export const UmbElementMixin = <T extends HTMLElementConstructor>(superClass: T)
? U | undefined
: U
: undefined,
R extends UmbObserverController<SpecificT> = UmbObserverController<SpecificT>,
SpecificR = ObservableType extends undefined ? R | undefined : R,
SpecificR = ObservableType extends undefined
? UmbObserverController<SpecificT> | undefined
: UmbObserverController<SpecificT>,
>(
// This type dance checks if the Observable given could be undefined, if it potentially could be undefined it means that this potentially could return undefined and then call the callback with undefined. [NL]
source: ObservableType,

View File

@@ -180,7 +180,6 @@ describe('UmbElement', () => {
// The controller is removed from the host, and the new one was NOT added:
expect(hostElement.hasController(ctrl)).to.be.false;
expect(ctrl2).to.be.undefined;
expect(hostElement.hasController(ctrl2)).to.be.false;
});
it('observe is removed when observer is undefined and using the same callback method', () => {
@@ -197,7 +196,6 @@ describe('UmbElement', () => {
// The controller is removed from the host, and the new one was NOT added:
expect(hostElement.hasController(ctrl)).to.be.false;
expect(ctrl2).to.be.undefined;
expect(hostElement.hasController(ctrl2)).to.be.false;
});
});
});