Skip to content

Commit 94dc794

Browse files
committed
client: Even more type checking improvements
1 parent ae921b7 commit 94dc794

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

client/js/requests/items.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ function enrichItemsResponse(data: RawItemsResponse): ItemsResponse {
142142

143143
type QueryFilter = {
144144
fromDatetime?: Date;
145+
itemsPerPage?: number;
145146
};
146147

147148
/**

client/js/selfoss-base.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ class selfoss {
456456
): void {
457457
const awaitStateChange = (): void => {
458458
reg.installing.addEventListener('statechange', (event) => {
459-
if (event.target.state === 'installed') {
459+
// https://github.com/microsoft/TypeScript/issues/40153
460+
const sw = event.target as ServiceWorker;
461+
if (sw.state === 'installed') {
460462
callback(reg);
461463
}
462464
});

client/js/selfoss-db-offline.ts

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import selfoss from './selfoss-base';
22
import { OfflineStorageNotAvailableError } from './errors';
3-
import Dexie from 'dexie';
3+
import Dexie, {
4+
PromiseExtended,
5+
Table,
6+
Transaction,
7+
TransactionMode,
8+
} from 'dexie';
49
import { OfflineDb } from './model/OfflineDb';
510
import { FilterType } from './Filter';
611

7-
const ENTRY_STATUS_NAMES = ['unread', 'starred'];
12+
const ENTRY_STATUS_NAMES: Array<'unread' | 'starred'> = ['unread', 'starred'];
813

914
export default class DbOffline {
1015
/** @var Date the datetime of the newest garbage collected entry, i.e. deleted because not of interest. */
@@ -17,25 +22,31 @@ export default class DbOffline {
1722
public olderEntriesOnline: boolean = false;
1823
public needsSync: boolean;
1924

20-
_tr(...args) {
21-
return selfoss.db.storage.transaction(...args).catch((error) => {
22-
selfoss.app.showError(
23-
selfoss.app._('error_offline_storage', {
24-
'0': error.message,
25-
}),
26-
);
27-
selfoss.db.broken = true;
28-
selfoss.db.enableOffline.update(false);
29-
selfoss.entries?.reload();
30-
31-
// If this is a QuotaExceededError, garbage collect more
32-
// entries and hope it helps.
33-
if (error.name === Dexie.errnames.QuotaExceeded) {
34-
this.GCEntries(true);
35-
}
25+
_tr<U>(
26+
mode: TransactionMode,
27+
tables: Table[],
28+
scope: (trans: Transaction) => PromiseLike<U> | U,
29+
): PromiseExtended<U> {
30+
return selfoss.db.storage
31+
.transaction(mode, tables, scope)
32+
.catch((error) => {
33+
selfoss.app.showError(
34+
selfoss.app._('error_offline_storage', {
35+
'0': error.message,
36+
}),
37+
);
38+
selfoss.db.broken = true;
39+
selfoss.db.enableOffline.update(false);
40+
selfoss.entries?.reload();
3641

37-
return Promise.reject(error);
38-
});
42+
// If this is a QuotaExceededError, garbage collect more
43+
// entries and hope it helps.
44+
if (error.name === Dexie.errnames.QuotaExceeded) {
45+
this.GCEntries(true);
46+
}
47+
48+
return Promise.reject(error);
49+
});
3950
}
4051

4152
init() {

client/js/templates/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ function PureApp(props: PureAppProps): React.JSX.Element {
445445
}
446446

447447
type AppProps = {
448-
configuration: object;
448+
configuration: Configuration;
449449
};
450450

451451
type AppState = {

0 commit comments

Comments
 (0)