Properly convert dataflow-assertions to simple values to allow the `is` check to work

This commit is contained in:
Tony Garnock-Jones 2024-05-28 22:27:53 +02:00
parent 25c701cd4e
commit ff1b013d66
1 changed files with 5 additions and 1 deletions

View File

@ -80,7 +80,10 @@ export function toRef(_v: any): Ref | undefined {
return isRef(_v) ? _v : void 0;
}
export function assertionFrom(a: Assertable): Assertion {
export function assertionFrom(a: Assertable): Assertion;
export function assertionFrom(a: Assertable | undefined): Assertion | undefined;
export function assertionFrom(a: Assertable | undefined): Assertion | undefined {
if (a === void 0) return void 0;
if (typeof a === 'object' && '__as_preserve__' in a) {
return fromJS(a);
} else {
@ -464,6 +467,7 @@ export class Turn {
let assertion: Assertable | undefined = void 0;
this.dataflow(() => {
let {target: nextTarget, assertion: nextAssertion} = assertionFunction();
nextAssertion = assertionFrom(nextAssertion);
if (target !== nextTarget || !is(assertion, nextAssertion)) {
target = nextTarget;
assertion = nextAssertion;