Skip to content

Commit 2e92a2e

Browse files
committed
client: Even more type checking improvements
1 parent 6850afa commit 2e92a2e

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
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
@@ -454,7 +454,9 @@ class selfoss {
454454
): void {
455455
const awaitStateChange = (): void => {
456456
reg.installing.addEventListener('statechange', (event) => {
457-
if (event.target.state === 'installed') {
457+
// https://github.com/microsoft/TypeScript/issues/40153
458+
const sw = event.target as ServiceWorker;
459+
if (sw.state === 'installed') {
458460
callback(reg);
459461
}
460462
});

client/js/selfoss-db-offline.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
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';
11+
import dexie from 'dexie';
612

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

915
export default class DbOffline {
1016
/** @var Date the datetime of the newest garbage collected entry, i.e. deleted because not of interest. */
@@ -17,23 +23,29 @@ export default class DbOffline {
1723
public olderEntriesOnline: boolean = false;
1824
public needsSync: boolean;
1925

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

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

3951
init() {

client/js/templates/App.tsx

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

473473
type AppProps = {
474-
configuration: object;
474+
configuration: Configuration;
475475
};
476476

477477
type AppState = {

0 commit comments

Comments
 (0)