Skip to content

Commit 2a9febb

Browse files
committed
Fix types in test
1 parent ea88c26 commit 2a9febb

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

.changeset/seven-seahorses-cry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
"@preact/signals-core": patch
2+
"@preact/signals-core": minor
33
---
44

55
Adjust ReadOnlySignal to not inherit from `Signal`

packages/core/test/signal.test.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
batch,
66
Signal,
77
untracked,
8+
ReadonlySignal,
89
} from "@preact/signals-core";
910

1011
describe("signal", () => {
@@ -962,15 +963,15 @@ describe("computed()", () => {
962963
});
963964

964965
it("should detect simple dependency cycles", () => {
965-
const a: Signal = computed(() => a.value);
966+
const a: ReadonlySignal = computed(() => a.value);
966967
expect(() => a.value).to.throw(/Cycle detected/);
967968
});
968969

969970
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);
974975
expect(() => a.value).to.throw(/Cycle detected/);
975976
});
976977

@@ -1243,15 +1244,15 @@ describe("computed()", () => {
12431244
});
12441245

12451246
it("should detect simple dependency cycles", () => {
1246-
const a: Signal = computed(() => a.peek());
1247+
const a: ReadonlySignal = computed(() => a.peek());
12471248
expect(() => a.peek()).to.throw(/Cycle detected/);
12481249
});
12491250

12501251
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());
12551256
expect(() => a.peek()).to.throw(/Cycle detected/);
12561257
});
12571258

@@ -1340,7 +1341,7 @@ describe("computed()", () => {
13401341
it("should be garbage collectable after it has lost all of its listeners", async () => {
13411342
const s = signal(0);
13421343

1343-
let ref: WeakRef<Signal>;
1344+
let ref: WeakRef<ReadonlySignal>;
13441345
let dispose: () => void;
13451346
(function () {
13461347
const c = computed(() => s.value);

packages/preact/test/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ describe("@preact/signals", () => {
382382
const childSpy = sinon.spy();
383383
const parentSpy = sinon.spy();
384384

385-
function Child({ num }: { num: Signal<number> }) {
385+
function Child({ num }: { num: ReadonlySignal<number> }) {
386386
childSpy();
387387
return <p>{num.value}</p>;
388388
}

packages/react/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ declare module "@preact/signals-core" {
3939
// @ts-ignore internal Signal is viewed as function
4040
// eslint-disable-next-line @typescript-eslint/no-empty-interface
4141
interface Signal extends ReactElement {}
42+
// @ts-ignore internal Signal is viewed as function
43+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
44+
interface ReadonlySignal extends ReactElement {}
4245
}

packages/react/test/shared/updates.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ export function updateSignalsTests(usingTransform = false) {
630630
const childSpy = sinon.spy();
631631
const parentSpy = sinon.spy();
632632

633-
function Child({ num }: { num: Signal<number> }) {
633+
function Child({ num }: { num: ReadonlySignal<number> }) {
634634
childSpy();
635635
return <p>{num.value}</p>;
636636
}

0 commit comments

Comments
 (0)