Skip to content

Commit d1ba6c8

Browse files
committed
Test compilation shenanigans
1 parent bbb7538 commit d1ba6c8

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

renderers/web_core/src/v0_9/reactivity/signals.angular.test.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-nocheck
21
/**
32
* Copyright 2026 Google LLC
43
*
@@ -18,36 +17,43 @@
1817
import {
1918
signal,
2019
computed,
21-
Signal,
22-
WritableSignal,
2320
isSignal,
2421
effect,
22+
Signal as NgSignal,
23+
WritableSignal as NgWritableSignal,
2524
} from '@angular/core';
2625

2726
import {FrameworkSignal} from './signals.js';
2827
import {runFrameworkSignalTests} from './signals-testing.shared.js';
2928

3029
declare module './signals.js' {
30+
// Setup the appropriate types for Angular Signals
3131
interface SignalKinds<T> {
32-
readonly: Signal<T>;
33-
writable: WritableSignal<T>;
32+
// @ts-ignore : Suppress cross-compilation interface overlap
33+
readonly: NgSignal<T>;
34+
// @ts-ignore : Suppress cross-compilation interface overlap
35+
writable: NgWritableSignal<T>;
3436
}
3537
}
3638

3739
// Test FrameworkSignal with Angular signals explicitly mapped over SignalKinds.
3840
const AngularSignal = {
3941
computed: <T>(fn: () => T) => computed(fn),
40-
isSignal: (val: unknown): val is Signal<any> => isSignal(val),
42+
isSignal: (val: unknown): val is NgSignal<any> => isSignal(val),
4143
wrap: <T>(val: T) => signal(val),
42-
unwrap: <T>(val: Signal<T>) => val(),
43-
set: <T>(sig: WritableSignal<T>, value: T) => sig.set(value),
44+
unwrap: <T>(val: NgSignal<T>) => val(),
45+
set: <T>(sig: NgWritableSignal<T>, value: T) => sig.set(value),
4446
effect: (fn: () => void, cleanupCallback: () => void) => {
4547
const e = effect(cleanupRegisterFn => {
4648
cleanupRegisterFn(cleanupCallback);
4749
fn();
4850
});
4951
return () => e.destroy();
5052
},
51-
} satisfies FrameworkSignal;
53+
} as unknown as FrameworkSignal; // Bypass Mono-compilation interface overlap
54+
// The cast above is needed because tsc is merging all our test files together,
55+
// and the SignalKinds interface is being declared multiple times, causing a
56+
// type collision. Normally, the AngularSignal would `satisfies FrameworkSignal`,
57+
// and the declaration of SignalKinds wouldn't need to suppress anything.
5258

5359
runFrameworkSignalTests('Angular implementation', AngularSignal);
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-nocheck
21
/**
32
* Copyright 2026 Google LLC
43
*
@@ -15,30 +14,32 @@
1514
* limitations under the License.
1615
*/
1716

18-
import {
19-
Signal,
20-
computed,
21-
effect,
22-
} from '@preact/signals-core';
17+
import {computed, effect, Signal as PSignal} from '@preact/signals-core';
2318

2419
import {FrameworkSignal} from './signals.js';
2520
import {runFrameworkSignalTests} from './signals-testing.shared.js';
2621

2722
declare module './signals.js' {
2823
interface SignalKinds<T> {
29-
readonly: Signal<T>;
30-
writable: Signal<T>;
24+
// @ts-ignore : Suppress cross-compilation interface overlap
25+
readonly: PSignal<T>;
26+
// @ts-ignore : Suppress cross-compilation interface overlap
27+
writable: PSignal<T>;
3128
}
3229
}
3330

3431
// Test FrameworkSignal with Preact signals explicitly mapped over SignalKinds.
3532
const PreactSignal = {
3633
computed: <T>(fn: () => T) => computed(fn),
37-
isSignal: (val: unknown): val is Signal<any> => val instanceof Signal,
38-
wrap: <T>(val: T) => new Signal(val),
39-
unwrap: <T>(val: Signal<T>) => val.value,
40-
set: <T>(sig: Signal<T>, value: T) => (sig.value = value),
34+
isSignal: (val: unknown): val is PSignal<any> => val instanceof PSignal,
35+
wrap: <T>(val: T) => new PSignal(val),
36+
unwrap: <T>(val: PSignal<T>) => val.value,
37+
set: <T>(sig: PSignal<T>, value: T) => (sig.value = value),
4138
effect: (fn: () => void) => effect(fn),
42-
} satisfies FrameworkSignal;
39+
} as unknown as FrameworkSignal; // Cast bypasses Mono-compilation interface overlap
40+
// The cast above is needed because tsc is merging all our test files together,
41+
// and the SignalKinds interface is being declared multiple times, causing a
42+
// type collision. Normally, the AngularSignal would `satisfies FrameworkSignal`,
43+
// and the declaration of SignalKinds wouldn't need to suppress anything.
4344

4445
runFrameworkSignalTests('Preact implementation', PreactSignal);

0 commit comments

Comments
 (0)