|
5 | 5 | batch,
|
6 | 6 | Signal,
|
7 | 7 | untracked,
|
| 8 | + ReadonlySignal, |
8 | 9 | } from "@preact/signals-core";
|
9 | 10 |
|
10 | 11 | describe("signal", () => {
|
@@ -962,15 +963,15 @@ describe("computed()", () => {
|
962 | 963 | });
|
963 | 964 |
|
964 | 965 | it("should detect simple dependency cycles", () => {
|
965 |
| - const a: Signal = computed(() => a.value); |
| 966 | + const a: ReadonlySignal = computed(() => a.value); |
966 | 967 | expect(() => a.value).to.throw(/Cycle detected/);
|
967 | 968 | });
|
968 | 969 |
|
969 | 970 | it("should detect deep dependency cycles", () => {
|
970 |
| - const a: Signal = computed(() => b.value); |
971 |
| - const b: Signal = computed(() => c.value); |
972 |
| - const c: Signal = computed(() => d.value); |
973 |
| - const d: Signal = computed(() => a.value); |
| 971 | + const a: ReadonlySignal = computed(() => b.value); |
| 972 | + const b: ReadonlySignal = computed(() => c.value); |
| 973 | + const c: ReadonlySignal = computed(() => d.value); |
| 974 | + const d: ReadonlySignal = computed(() => a.value); |
974 | 975 | expect(() => a.value).to.throw(/Cycle detected/);
|
975 | 976 | });
|
976 | 977 |
|
@@ -1243,15 +1244,15 @@ describe("computed()", () => {
|
1243 | 1244 | });
|
1244 | 1245 |
|
1245 | 1246 | it("should detect simple dependency cycles", () => {
|
1246 |
| - const a: Signal = computed(() => a.peek()); |
| 1247 | + const a: ReadonlySignal = computed(() => a.peek()); |
1247 | 1248 | expect(() => a.peek()).to.throw(/Cycle detected/);
|
1248 | 1249 | });
|
1249 | 1250 |
|
1250 | 1251 | it("should detect deep dependency cycles", () => {
|
1251 |
| - const a: Signal = computed(() => b.value); |
1252 |
| - const b: Signal = computed(() => c.value); |
1253 |
| - const c: Signal = computed(() => d.value); |
1254 |
| - const d: Signal = computed(() => a.peek()); |
| 1252 | + const a: ReadonlySignal = computed(() => b.value); |
| 1253 | + const b: ReadonlySignal = computed(() => c.value); |
| 1254 | + const c: ReadonlySignal = computed(() => d.value); |
| 1255 | + const d: ReadonlySignal = computed(() => a.peek()); |
1255 | 1256 | expect(() => a.peek()).to.throw(/Cycle detected/);
|
1256 | 1257 | });
|
1257 | 1258 |
|
@@ -1340,7 +1341,7 @@ describe("computed()", () => {
|
1340 | 1341 | it("should be garbage collectable after it has lost all of its listeners", async () => {
|
1341 | 1342 | const s = signal(0);
|
1342 | 1343 |
|
1343 |
| - let ref: WeakRef<Signal>; |
| 1344 | + let ref: WeakRef<ReadonlySignal>; |
1344 | 1345 | let dispose: () => void;
|
1345 | 1346 | (function () {
|
1346 | 1347 | const c = computed(() => s.value);
|
|
0 commit comments