@@ -47,7 +47,7 @@ export interface InternalSignal<T = any> extends InternalReadonlySignal<T> {
47
47
untrackedValue : T ;
48
48
}
49
49
50
- export const throwIfQRLNotResolved = < T > ( qrl : QRL < ( ) => T > ) => {
50
+ export const throwIfQRLNotResolved = ( qrl : QRL ) => {
51
51
const resolved = qrl . resolved ;
52
52
if ( ! resolved ) {
53
53
// When we are creating a signal using a use method, we need to ensure
@@ -205,7 +205,6 @@ export class Signal<T = any> implements ISignal<T> {
205
205
}
206
206
return this . untrackedValue ;
207
207
}
208
-
209
208
set value ( value ) {
210
209
if ( value !== this . $untrackedValue$ ) {
211
210
DEBUG &&
@@ -374,6 +373,8 @@ export const triggerEffects = (
374
373
DEBUG && log ( 'done scheduling' ) ;
375
374
} ;
376
375
376
+ type ComputeQRL < T > = QRLInternal < ( prev : T | undefined ) => T > ;
377
+
377
378
/**
378
379
* A signal which is computed from other signals.
379
380
*
@@ -386,13 +387,13 @@ export class ComputedSignal<T> extends Signal<T> {
386
387
* The computed functions must be executed synchronously (because of this we need to eagerly
387
388
* resolve the QRL during the mark dirty phase so that any call to it will be synchronous). )
388
389
*/
389
- $computeQrl$ : QRLInternal < ( ) => T > ;
390
+ $computeQrl$ : ComputeQRL < T > ;
390
391
// We need a separate flag to know when the computation needs running because
391
392
// we need the old value to know if effects need running after computation
392
393
$invalid$ : boolean = true ;
393
394
$forceRunEffects$ : boolean = false ;
394
395
395
- constructor ( container : Container | null , fn : QRLInternal < ( ) => T > ) {
396
+ constructor ( container : Container | null , fn : ComputeQRL < T > ) {
396
397
// The value is used for comparison when signals trigger, which can only happen
397
398
// when it was calculated before. Therefore we can pass whatever we like.
398
399
super ( container , NEEDS_COMPUTATION ) ;
@@ -459,14 +460,14 @@ export class ComputedSignal<T> extends Signal<T> {
459
460
}
460
461
}
461
462
462
- // Getters don't get inherited
463
- get value ( ) {
464
- return super . value ;
465
- }
466
-
463
+ // Make this signal read-only
467
464
set value ( _ : any ) {
468
465
throw qError ( QError . computedReadOnly ) ;
469
466
}
467
+ // Getters don't get inherited when overriding a setter
468
+ get value ( ) {
469
+ return super . value ;
470
+ }
470
471
}
471
472
472
473
export class WrappedSignal < T > extends Signal < T > implements Subscriber {
@@ -540,13 +541,12 @@ export class WrappedSignal<T> extends Signal<T> implements Subscriber {
540
541
}
541
542
return didChange ;
542
543
}
543
-
544
- // Getters don't get inherited
545
- get value ( ) {
546
- return super . value ;
547
- }
548
-
544
+ // Make this signal read-only
549
545
set value ( _ : any ) {
550
546
throw qError ( QError . wrappedReadOnly ) ;
551
547
}
548
+ // Getters don't get inherited when overriding a setter
549
+ get value ( ) {
550
+ return super . value ;
551
+ }
552
552
}
0 commit comments