Skip to content

Commit 6500808

Browse files
committed
chore: enable isolatedDeclarations
1 parent 9439f1f commit 6500808

File tree

7 files changed

+32
-31
lines changed

7 files changed

+32
-31
lines changed

src/computed.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Computed<T = any> implements IComputed {
1919
deps: Link | undefined = undefined;
2020
depsTail: Link | undefined = undefined;
2121
trackId = 0;
22-
dirtyLevel = DirtyLevels.Dirty;
22+
dirtyLevel: DirtyLevels = DirtyLevels.Dirty;
2323
canPropagate = false;
2424

2525
constructor(
@@ -45,7 +45,7 @@ export class Computed<T = any> implements IComputed {
4545
return this.cachedValue!;
4646
}
4747

48-
update() {
48+
update(): void {
4949
const prevSub = Subscriber.startTrack(this);
5050
const oldValue = this.cachedValue;
5151
let newValue: T;

src/effect.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { activeEffectScope } from './effectScope.js';
22
import { Dependency, DirtyLevels, IEffect, Link, Subscriber, System } from './system.js';
33

4-
export function effect(fn: () => void) {
4+
export function effect(fn: () => void): Effect<void> {
55
const e = new Effect(fn);
66
e.run();
77
return e;
@@ -18,7 +18,7 @@ export class Effect<T = any> implements IEffect {
1818
deps: Link | undefined = undefined;
1919
depsTail: Link | undefined = undefined;
2020
trackId = 0;
21-
dirtyLevel = DirtyLevels.Dirty;
21+
dirtyLevel: DirtyLevels = DirtyLevels.Dirty;
2222
canPropagate = false;
2323

2424
constructor(
@@ -37,7 +37,7 @@ export class Effect<T = any> implements IEffect {
3737
}
3838
}
3939

40-
notify() {
40+
notify(): void {
4141
let dirtyLevel = this.dirtyLevel;
4242
if (dirtyLevel > DirtyLevels.None) {
4343
if (dirtyLevel === DirtyLevels.MaybeDirty) {
@@ -53,7 +53,7 @@ export class Effect<T = any> implements IEffect {
5353
}
5454
}
5555

56-
run() {
56+
run(): T {
5757
const prevSub = Subscriber.startTrack(this);
5858
try {
5959
return this.fn();
@@ -62,7 +62,7 @@ export class Effect<T = any> implements IEffect {
6262
}
6363
}
6464

65-
stop() {
65+
stop(): void {
6666
if (this.deps !== undefined) {
6767
Subscriber.clearTrack(this.deps);
6868
this.deps = undefined;

src/effectScope.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ import { DirtyLevels, Link, Subscriber, System } from './system.js';
22

33
export let activeEffectScope: EffectScope | undefined = undefined;
44

5-
export function effectScope() {
5+
export function effectScope(): EffectScope {
66
return new EffectScope();
77
}
88

99
export class EffectScope implements Subscriber {
1010
// Subscriber
1111
deps: Link | undefined = undefined;
1212
depsTail: Link | undefined = undefined;
13-
trackId = -(++System.lastTrackId);
14-
dirtyLevel = DirtyLevels.None;
13+
trackId: number = -(++System.lastTrackId);
14+
dirtyLevel: DirtyLevels = DirtyLevels.None;
1515
canPropagate = false;
1616

17-
notify() {
17+
notify(): void {
1818
if (this.dirtyLevel !== DirtyLevels.None) {
1919
this.dirtyLevel = DirtyLevels.None;
2020
Subscriber.runInnerEffects(this.deps);
2121
}
2222
}
2323

24-
run<T>(fn: () => T) {
24+
run<T>(fn: () => T): T {
2525
const prevSub = activeEffectScope;
2626
activeEffectScope = this;
2727
this.trackId = Math.abs(this.trackId);
@@ -33,7 +33,7 @@ export class EffectScope implements Subscriber {
3333
}
3434
}
3535

36-
stop() {
36+
stop(): void {
3737
if (this.deps !== undefined) {
3838
Subscriber.clearTrack(this.deps);
3939
this.deps = undefined;

src/signal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class Signal<T = any> implements Dependency {
2020
public currentValue: T
2121
) { }
2222

23-
get() {
23+
get(): NonNullable<T> {
2424
const activeTrackId = System.activeTrackId;
2525
if (activeTrackId !== 0) {
2626
const subsTail = this.subsTail;
@@ -31,7 +31,7 @@ export class Signal<T = any> implements Dependency {
3131
return this.currentValue!;
3232
}
3333

34-
set(value: T) {
34+
set(value: T): void {
3535
if (this.currentValue !== (this.currentValue = value)) {
3636
const subs = this.subs;
3737
if (subs !== undefined) {

src/system.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export namespace System {
4848
export let queuedEffectsTail: IEffect | undefined = undefined;
4949
}
5050

51-
export function startBatch() {
51+
export function startBatch(): void {
5252
System.batchDepth++;
5353
}
5454

55-
export function endBatch() {
55+
export function endBatch(): void {
5656
System.batchDepth--;
5757
if (System.batchDepth === 0) {
5858
while (System.queuedEffects !== undefined) {
@@ -73,7 +73,7 @@ export function endBatch() {
7373
export namespace Link {
7474
let pool: Link | undefined = undefined;
7575

76-
export function get(dep: Dependency, sub: Subscriber, nextDep: Link | undefined) {
76+
export function get(dep: Dependency, sub: Subscriber, nextDep: Link | undefined): Link {
7777
if (pool !== undefined) {
7878
const newLink = pool;
7979
pool = newLink.nextDep;
@@ -94,7 +94,7 @@ export namespace Link {
9494
}
9595
}
9696

97-
export function release(link: Link) {
97+
export function release(link: Link): void {
9898
const dep = link.dep;
9999
const nextSub = link.nextSub;
100100
const prevSub = link.prevSub;
@@ -131,11 +131,11 @@ export namespace Dependency {
131131
/**
132132
* @deprecated Use `startTrack` instead.
133133
*/
134-
export function linkSubscriber(dep: Dependency, sub: Subscriber) {
134+
export function linkSubscriber(dep: Dependency, sub: Subscriber): void {
135135
return link(dep, sub);
136136
}
137137

138-
export function link(dep: Dependency, sub: Subscriber) {
138+
export function link(dep: Dependency, sub: Subscriber): void {
139139
const depsTail = sub.depsTail;
140140
const old = depsTail !== undefined
141141
? depsTail.nextDep
@@ -166,7 +166,7 @@ export namespace Dependency {
166166
}
167167
}
168168

169-
export function propagate(subs: Link) {
169+
export function propagate(subs: Link): void {
170170
let link: Link | undefined = subs;
171171
let dep = subs.dep;
172172
let dirtyLevel = DirtyLevels.Dirty;
@@ -282,7 +282,7 @@ export namespace Subscriber {
282282

283283
const system = System;
284284

285-
export function runInnerEffects(link: Link | undefined) {
285+
export function runInnerEffects(link: Link | undefined): void {
286286
while (link !== undefined) {
287287
const dep = link.dep;
288288
if ('notify' in dep) {
@@ -292,7 +292,7 @@ export namespace Subscriber {
292292
}
293293
}
294294

295-
export function resolveMaybeDirty(sub: IComputed | IEffect, depth = 0) {
295+
export function resolveMaybeDirty(sub: IComputed | IEffect, depth = 0): void {
296296
let link = sub.deps;
297297

298298
while (link !== undefined) {
@@ -327,7 +327,7 @@ export namespace Subscriber {
327327
}
328328
}
329329

330-
export function resolveMaybeDirtyNonRecursive(sub: IComputed | IEffect) {
330+
export function resolveMaybeDirtyNonRecursive(sub: IComputed | IEffect): void {
331331
let link = sub.deps;
332332
let remaining = 0;
333333

@@ -402,18 +402,18 @@ export namespace Subscriber {
402402
/**
403403
* @deprecated Use `startTrack` instead.
404404
*/
405-
export function startTrackDependencies(sub: Subscriber) {
405+
export function startTrackDependencies(sub: Subscriber): Subscriber | undefined {
406406
return startTrack(sub);
407407
}
408408

409409
/**
410410
* @deprecated Use `endTrack` instead.
411411
*/
412-
export function endTrackDependencies(sub: Subscriber, prevSub: Subscriber | undefined) {
412+
export function endTrackDependencies(sub: Subscriber, prevSub: Subscriber | undefined): void {
413413
return endTrack(sub, prevSub);
414414
}
415415

416-
export function startTrack(sub: Subscriber) {
416+
export function startTrack(sub: Subscriber): Subscriber | undefined {
417417
const newTrackId = system.lastTrackId + 1;
418418
const prevSub = system.activeSub;
419419

@@ -428,7 +428,7 @@ export namespace Subscriber {
428428
return prevSub;
429429
}
430430

431-
export function endTrack(sub: Subscriber, prevSub: Subscriber | undefined) {
431+
export function endTrack(sub: Subscriber, prevSub: Subscriber | undefined): void {
432432
if (prevSub !== undefined) {
433433
system.activeSub = prevSub;
434434
system.activeTrackId = prevSub.trackId;
@@ -450,7 +450,7 @@ export namespace Subscriber {
450450
sub.trackId = -sub.trackId;
451451
}
452452

453-
export function clearTrack(link: Link) {
453+
export function clearTrack(link: Link): void {
454454
do {
455455
const dep = link.dep;
456456
const nextDep = link.nextDep;

src/unstable/computedSet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { computed, ISignal } from '../index.js';
22

3-
export function computedSet<T>(source: ISignal<Set<T>>) {
3+
export function computedSet<T>(source: ISignal<Set<T>>): ISignal<Set<T>> {
44
return computed<Set<T>>(
55
(oldValue) => {
66
const newValue = source.get();

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"noUnusedLocals": true,
99
"noUnusedParameters": true,
1010
"skipLibCheck": true,
11+
"isolatedDeclarations": true,
1112
"rootDir": "src",
1213
"outDir": "cjs",
1314
},

0 commit comments

Comments
 (0)