Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: Port to TypeScript #1457

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-eval": "error",
"array-bracket-spacing": "error",
Expand Down Expand Up @@ -43,7 +49,9 @@
"space-before-function-paren": ["error", "never"],
"space-in-parens": "error",
"space-infix-ops": "error",
"unicode-bom": "error"
"unicode-bom": "error",
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-unused-vars": 0
},
"env": {
"browser": true,
Expand Down
2 changes: 1 addition & 1 deletion client/images/wallabag.js → client/images/wallabag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export default [
[],
null,
// wallabag.svg: Free Art License 1.3 https://github.com/wallabag/logo
'M108.69.004c-.241-.026-.512.083-.777.299-.572.465-5.551 1.614-8.504 3.917-4.768 3.72-7.707 10.796-9.04 14.708-.024.06-.205.603-.265.79-.62 1.499-1.857 1.495-1.857 1.495v.002c-.6-.065-1.202-.102-1.809-.102-.54 0-1.078.03-1.615.082-.012.002-.02 0-.031 0-1.581.233-2.451-1.696-2.633-2.156C80.312 13.735 75.342 3.277 64.174.463c0 0-2.028-1.554-1.41 1.074.588 2.51 1.805 5.048 1.535 8.74-.124 1.704-1.18 10.442 6.85 14.99.763.432 1.44.796 2.05 1.102-4.041 3.235-7.715 7.739-10.858 12.852 1.597-.981 10.206-5.557 24.097.177 14.29 5.897 23.155.777 24.254.08-3.454-5.678-7.561-10.62-12.103-13.943.303-.083.612-.168.939-.264 6.023-1.742 7.553-6.84 7.875-11.209.364-4.954.615-5.029 1.691-9.486.774-3.21.32-4.495-.404-4.572zM86.774 50.228a4.677 4.677 0 00-1.652.256 6.555 6.555 0 00-1.332.615 3.879 3.879 0 00-1.094.985c-.322.432-.486.901-.486 1.396v16.307c0 2.158-.362 3.75-1.078 4.73-.688.94-1.85 1.397-3.55 1.397-1.704 0-2.876-.46-3.583-1.402-.734-.98-1.108-2.57-1.108-4.725V53.73c0-.908-.383-1.727-1.144-2.437-.751-.702-1.75-1.059-2.973-1.059-1.258 0-2.297.352-3.086 1.045-.81.71-1.22 1.536-1.22 2.451v15.807c0 1.988.193 3.869.574 5.588.393 1.758 1.077 3.3 2.035 4.586.968 1.299 2.282 2.322 3.906 3.049 1.607.716 3.617 1.08 5.975 1.08 2.457 0 4.515-.457 6.115-1.356a10.678 10.678 0 003.371-2.95 10.256 10.256 0 003.295 2.95c1.58.9 3.669 1.354 6.21 1.354 2.358 0 4.358-.363 5.946-1.08 1.601-.726 2.903-1.752 3.873-3.05.96-1.29 1.644-2.832 2.033-4.585.381-1.72.577-3.6.577-5.588V53.73c0-.91-.398-1.733-1.184-2.445-.767-.697-1.82-1.05-3.121-1.05-1.181 0-2.161.356-2.912 1.058-.76.71-1.145 1.53-1.145 2.437v16.057c0 2.154-.381 3.742-1.134 4.72-.728.947-1.891 1.407-3.555 1.407-1.703 0-2.863-.458-3.549-1.397-.716-.979-1.078-2.57-1.078-4.73v-16.12c0-1.097-.501-1.997-1.45-2.597-.805-.507-1.607-.81-2.476-.842zM51.796 82.363a31.2 31.2 0 001.865 5.742c.666 3.745 1.561 12.563-2.674 20.282-3.731 6.8-22.15 16.069-49.484 10.748 0 0-1.096-.765-1.428-.135-.491.932 1.516 1.684 3.582 2.228 19.03 5.04 47.756 2.989 56.777-4.443 4.116-3.388 5.705-7.953 6.108-12.865l.002.008s.11-1.288 1.718-.32c.461.276 2.126 1.36 2.391 2.585.232 1.743.248 3.884-.652 5.383-1.287 2.144-1.302 2.45.392 3.66 1.04.742 5.289 3.865 11.2 7.416.015.01.022.02.037.028 1.25.753 2.988 2.595 2.988 2.595 2.662 3.08 8.45 9.277 10.97 8.11 1.19-.551-.05-3.033-.05-3.033s1.98 2.572 3.043 1.695c.809-.668-.473-3.23-.473-3.23s1.73 1.5 2.758.945c1.258-.68-.188-4.614-10.08-10.627-9.896-6.018-12.579-6.941-12.815-9.627 0 0-.004-.134.004-.365.077-.593.416-1.848 1.854-1.713 2.14.346 4.347.53 6.607.53 2.587 0 5.106-.236 7.535-.689l.002.002.164-.029c.284-.036.838-.019.84.67-.09.873-.331 1.752-.845 2.52-1.447 2.168-.971 2.466.54 3.859.934.859 5.212 4.622 11.07 8.264.013.009.016.016.03.023 1.25.752 3.41 2.814 3.41 2.814 2.428 2.466 6.895 6.595 9.328 6.346 1.646-.168.305-3.002.305-3.002s2.079 2.006 3.1 1.416c1.142-.659-.475-2.754-.475-2.754s1.338.708 2.283.473c.948-.236 1.187-2.643-8.654-8.736-9.842-6.098-13.154-8.244-12.947-10.577 0 0 .003-.379.1-.957.238-1.236.994-3.346 3.406-4.55.079-.04.147-.084.209-.13 7.668-4.45 13.27-11.614 15.246-20.56-1.99 4.941-16.737 8.78-34.647 8.78-17.903 0-32.65-3.839-34.64-8.78z'
'M108.69.004c-.241-.026-.512.083-.777.299-.572.465-5.551 1.614-8.504 3.917-4.768 3.72-7.707 10.796-9.04 14.708-.024.06-.205.603-.265.79-.62 1.499-1.857 1.495-1.857 1.495v.002c-.6-.065-1.202-.102-1.809-.102-.54 0-1.078.03-1.615.082-.012.002-.02 0-.031 0-1.581.233-2.451-1.696-2.633-2.156C80.312 13.735 75.342 3.277 64.174.463c0 0-2.028-1.554-1.41 1.074.588 2.51 1.805 5.048 1.535 8.74-.124 1.704-1.18 10.442 6.85 14.99.763.432 1.44.796 2.05 1.102-4.041 3.235-7.715 7.739-10.858 12.852 1.597-.981 10.206-5.557 24.097.177 14.29 5.897 23.155.777 24.254.08-3.454-5.678-7.561-10.62-12.103-13.943.303-.083.612-.168.939-.264 6.023-1.742 7.553-6.84 7.875-11.209.364-4.954.615-5.029 1.691-9.486.774-3.21.32-4.495-.404-4.572zM86.774 50.228a4.677 4.677 0 00-1.652.256 6.555 6.555 0 00-1.332.615 3.879 3.879 0 00-1.094.985c-.322.432-.486.901-.486 1.396v16.307c0 2.158-.362 3.75-1.078 4.73-.688.94-1.85 1.397-3.55 1.397-1.704 0-2.876-.46-3.583-1.402-.734-.98-1.108-2.57-1.108-4.725V53.73c0-.908-.383-1.727-1.144-2.437-.751-.702-1.75-1.059-2.973-1.059-1.258 0-2.297.352-3.086 1.045-.81.71-1.22 1.536-1.22 2.451v15.807c0 1.988.193 3.869.574 5.588.393 1.758 1.077 3.3 2.035 4.586.968 1.299 2.282 2.322 3.906 3.049 1.607.716 3.617 1.08 5.975 1.08 2.457 0 4.515-.457 6.115-1.356a10.678 10.678 0 003.371-2.95 10.256 10.256 0 003.295 2.95c1.58.9 3.669 1.354 6.21 1.354 2.358 0 4.358-.363 5.946-1.08 1.601-.726 2.903-1.752 3.873-3.05.96-1.29 1.644-2.832 2.033-4.585.381-1.72.577-3.6.577-5.588V53.73c0-.91-.398-1.733-1.184-2.445-.767-.697-1.82-1.05-3.121-1.05-1.181 0-2.161.356-2.912 1.058-.76.71-1.145 1.53-1.145 2.437v16.057c0 2.154-.381 3.742-1.134 4.72-.728.947-1.891 1.407-3.555 1.407-1.703 0-2.863-.458-3.549-1.397-.716-.979-1.078-2.57-1.078-4.73v-16.12c0-1.097-.501-1.997-1.45-2.597-.805-.507-1.607-.81-2.476-.842zM51.796 82.363a31.2 31.2 0 001.865 5.742c.666 3.745 1.561 12.563-2.674 20.282-3.731 6.8-22.15 16.069-49.484 10.748 0 0-1.096-.765-1.428-.135-.491.932 1.516 1.684 3.582 2.228 19.03 5.04 47.756 2.989 56.777-4.443 4.116-3.388 5.705-7.953 6.108-12.865l.002.008s.11-1.288 1.718-.32c.461.276 2.126 1.36 2.391 2.585.232 1.743.248 3.884-.652 5.383-1.287 2.144-1.302 2.45.392 3.66 1.04.742 5.289 3.865 11.2 7.416.015.01.022.02.037.028 1.25.753 2.988 2.595 2.988 2.595 2.662 3.08 8.45 9.277 10.97 8.11 1.19-.551-.05-3.033-.05-3.033s1.98 2.572 3.043 1.695c.809-.668-.473-3.23-.473-3.23s1.73 1.5 2.758.945c1.258-.68-.188-4.614-10.08-10.627-9.896-6.018-12.579-6.941-12.815-9.627 0 0-.004-.134.004-.365.077-.593.416-1.848 1.854-1.713 2.14.346 4.347.53 6.607.53 2.587 0 5.106-.236 7.535-.689l.002.002.164-.029c.284-.036.838-.019.84.67-.09.873-.331 1.752-.845 2.52-1.447 2.168-.971 2.466.54 3.859.934.859 5.212 4.622 11.07 8.264.013.009.016.016.03.023 1.25.752 3.41 2.814 3.41 2.814 2.428 2.466 6.895 6.595 9.328 6.346 1.646-.168.305-3.002.305-3.002s2.079 2.006 3.1 1.416c1.142-.659-.475-2.754-.475-2.754s1.338.708 2.283.473c.948-.236 1.187-2.643-8.654-8.736-9.842-6.098-13.154-8.244-12.947-10.577 0 0 .003-.379.1-.957.238-1.236.994-3.346 3.406-4.55.079-.04.147-.084.209-.13 7.668-4.45 13.27-11.614 15.246-20.56-1.99 4.941-16.737 8.78-34.647 8.78-17.903 0-32.65-3.839-34.64-8.78z',
];
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
document.getElementById('js-loading-message').textContent = 'selfoss is still loading, please wait.';
</script>

<script src="js/index.js" onerror="document.getElementById('js-loading-message').textContent = 'Error loading selfoss JavaScript file. Please check the browser console or your web server logs.'" type="module"></script>
<script src="js/index.ts" onerror="document.getElementById('js-loading-message').textContent = 'Error loading selfoss JavaScript file. Please check the browser console or your web server logs.'" type="module"></script>
</body>
</html>
9 changes: 0 additions & 9 deletions client/js/Filter.js

This file was deleted.

8 changes: 8 additions & 0 deletions client/js/Filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Object describing how feed items are filtered in the view.
*/
export enum FilterType {
NEWEST = 'newest',
UNREAD = 'unread',
STARRED = 'starred',
}
21 changes: 16 additions & 5 deletions client/js/errors.js → client/js/errors.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
export class OfflineStorageNotAvailableError extends Error {
constructor(message = 'Offline storage is not available') {
public name: string;

constructor(message: string = 'Offline storage is not available') {
super(message);
this.name = 'OfflineStorageNotAvailableError';
}
}

export class TimeoutError extends Error {
constructor(message) {
public name: string;

constructor(message: string) {
super(message);
this.name = 'TimeoutError';
}
}

export class HttpError extends Error {
constructor(message) {
public name: string;
public response: Response;

constructor(message: string) {
super(message);
this.name = 'HttpError';
}
}

export class LoginError extends Error {
constructor(message) {
public name: string;

constructor(message: string) {
super(message);
this.name = 'LoginError';
}
}

export class UnexpectedStateError extends Error {
constructor(message) {
public name: string;

constructor(message: string) {
super(message);
this.name = 'UnexpectedStateError';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export class ValueChangeEvent extends Event {
constructor(value) {
export class ValueChangeEvent<T> extends Event {
public value: T;

constructor(value: T) {
super('change');
this.value = value;
}
Expand All @@ -8,14 +10,16 @@ export class ValueChangeEvent extends Event {
/**
* Object storing a value and allowing subscribing to its changes.
*/
export class ValueListenable extends EventTarget {
constructor(value) {
export class ValueListenable<T> extends EventTarget {
public value: T;

constructor(value: T) {
super();

this.value = value;
}

update(value) {
update(value: T) {
if (this.value !== value) {
this.value = value;

Expand Down
188 changes: 0 additions & 188 deletions client/js/helpers/ajax.js

This file was deleted.

Loading
Loading