Skip to content

Commit aef4f13

Browse files
committed
fixup! client: Add more type annotations
1 parent e5477e0 commit aef4f13

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

client/js/errors.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export class OfflineStorageNotAvailableError extends Error {
22
public name: string;
33

4-
constructor(message = 'Offline storage is not available') {
4+
constructor(message: string = 'Offline storage is not available') {
55
super(message);
66
this.name = 'OfflineStorageNotAvailableError';
77
}
@@ -10,7 +10,7 @@ export class OfflineStorageNotAvailableError extends Error {
1010
export class TimeoutError extends Error {
1111
public name: string;
1212

13-
constructor(message) {
13+
constructor(message: string) {
1414
super(message);
1515
this.name = 'TimeoutError';
1616
}
@@ -20,7 +20,7 @@ export class HttpError extends Error {
2020
public name: string;
2121
public response: Response;
2222

23-
constructor(message) {
23+
constructor(message: string) {
2424
super(message);
2525
this.name = 'HttpError';
2626
}
@@ -29,7 +29,7 @@ export class HttpError extends Error {
2929
export class LoginError extends Error {
3030
public name: string;
3131

32-
constructor(message) {
32+
constructor(message: string) {
3333
super(message);
3434
this.name = 'LoginError';
3535
}
@@ -38,7 +38,7 @@ export class LoginError extends Error {
3838
export class UnexpectedStateError extends Error {
3939
public name: string;
4040

41-
constructor(message) {
41+
constructor(message: string) {
4242
super(message);
4343
this.name = 'UnexpectedStateError';
4444
}

client/js/helpers/uri.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generatePath } from 'react-router-dom';
2+
import { Location } from '@types/history';
23
import { FilterType } from '../Filter';
34

45
/**
@@ -31,7 +32,17 @@ export function filterTypeToString(type: FilterType): string {
3132

3233
export const ENTRIES_ROUTE_PATTERN = '/:filter(newest|unread|starred)/:category(all|tag-[^/]+|source-[0-9]+)/:id?';
3334

34-
export function makeEntriesLinkLocation(location, { filter, category, id, search }) {
35+
type EntriesLinkParams = {
36+
filter?: FilterType,
37+
category?: string,
38+
id?: number,
39+
search?: string,
40+
};
41+
42+
export function makeEntriesLinkLocation(
43+
location: Location,
44+
{ filter, category, id, search }: EntriesLinkParams,
45+
): Location {
3546
const queryString = new URLSearchParams(location.search);
3647

3748
let path;
@@ -66,13 +77,13 @@ export function makeEntriesLinkLocation(location, { filter, category, id, search
6677
};
6778
}
6879

69-
export function makeEntriesLink(location, params) {
80+
export function makeEntriesLink(location: Location, params: EntriesLinkParams): string {
7081
const { pathname, search } = makeEntriesLinkLocation(location, params);
7182

7283
return pathname + (search !== '' ? `?${search}` : '');
7384
}
7485

75-
export function forceReload(location): void {
86+
export function forceReload(location: Location): void {
7687
const state = location.state ?? {};
7788

7889
return {

0 commit comments

Comments
 (0)