From dc52cd042b76e2f3ec4c38d4b0a24ddee978afee Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 29 Sep 2021 18:20:33 +0200 Subject: [PATCH] Fix a typescript issue with catch variable type Signed-off-by: Thomas Citharel --- js/src/components/Admin/Followers.vue | 30 +++++++++++-------- js/src/components/Admin/Followings.vue | 30 +++++++++++-------- js/src/components/Comment/Comment.vue | 14 +++++---- js/src/components/Comment/CommentTree.vue | 4 +-- js/src/components/Editor.vue | 2 +- js/src/components/Group/Invitations.vue | 4 +-- .../ParticipationWithoutAccount.vue | 2 +- js/src/components/Resource/FolderItem.vue | 2 +- .../Settings/NotificationsOnboarding.vue | 2 +- js/src/components/Todo/CompactTodo.vue | 2 +- js/src/components/Todo/FullTodo.vue | 2 +- js/src/mixins/event.ts | 4 +-- js/src/views/Account/Register.vue | 2 +- js/src/views/Discussions/Create.vue | 2 +- js/src/views/Group/Create.vue | 2 +- js/src/views/Group/Group.vue | 4 +-- js/src/views/Group/GroupFollowers.vue | 2 +- js/src/views/Group/GroupMembers.vue | 6 ++-- js/src/views/Group/GroupSettings.vue | 2 +- js/src/views/Group/MyGroups.vue | 2 +- js/src/views/Posts/Edit.vue | 4 +-- js/src/views/Resources/ResourceFolder.vue | 10 +++---- js/src/views/Settings/AccountSettings.vue | 6 ++-- js/src/views/User/Login.vue | 4 +-- js/src/views/User/PasswordReset.vue | 2 +- js/src/views/User/Register.vue | 2 +- js/src/views/User/SendPasswordReset.vue | 14 +++++---- 27 files changed, 87 insertions(+), 75 deletions(-) diff --git a/js/src/components/Admin/Followers.vue b/js/src/components/Admin/Followers.vue index 828eaafde..d05b6d606 100644 --- a/js/src/components/Admin/Followers.vue +++ b/js/src/components/Admin/Followers.vue @@ -209,12 +209,14 @@ export default class Followers extends Mixins(RelayMixin) { }); await this.$apollo.queries.relayFollowers.refetch(); this.checkedRows = []; - } catch (e) { - Snackbar.open({ - message: e.message, - type: "is-danger", - position: "is-bottom", - }); + } catch (e: any) { + if (e.message) { + Snackbar.open({ + message: e.message, + type: "is-danger", + position: "is-bottom", + }); + } } } @@ -228,12 +230,14 @@ export default class Followers extends Mixins(RelayMixin) { }); await this.$apollo.queries.relayFollowers.refetch(); this.checkedRows = []; - } catch (e) { - Snackbar.open({ - message: e.message, - type: "is-danger", - position: "is-bottom", - }); + } catch (e: any) { + if (e.message) { + Snackbar.open({ + message: e.message, + type: "is-danger", + position: "is-bottom", + }); + } } } @@ -250,7 +254,7 @@ export default class Followers extends Mixins(RelayMixin) { limit: FOLLOWERS_PER_PAGE, }, }); - } catch (err) { + } catch (err: any) { console.error(err); } } diff --git a/js/src/components/Admin/Followings.vue b/js/src/components/Admin/Followings.vue index 46944e0cc..6739aba01 100644 --- a/js/src/components/Admin/Followings.vue +++ b/js/src/components/Admin/Followings.vue @@ -203,7 +203,7 @@ export default class Followings extends Mixins(RelayMixin) { limit: FOLLOWINGS_PER_PAGE, }, }); - } catch (err) { + } catch (err: any) { console.error(err); } } @@ -254,12 +254,14 @@ export default class Followings extends Mixins(RelayMixin) { }, }); this.newRelayAddress = ""; - } catch (err) { - Snackbar.open({ - message: err.message, - type: "is-danger", - position: "is-bottom", - }); + } catch (err: any) { + if (err.message) { + Snackbar.open({ + message: err.message, + type: "is-danger", + position: "is-bottom", + }); + } } } @@ -295,12 +297,14 @@ export default class Followings extends Mixins(RelayMixin) { }); await this.$apollo.queries.relayFollowings.refetch(); this.checkedRows = []; - } catch (e) { - Snackbar.open({ - message: e.message, - type: "is-danger", - position: "is-bottom", - }); + } catch (e: any) { + if (e.message) { + Snackbar.open({ + message: e.message, + type: "is-danger", + position: "is-bottom", + }); + } } } } diff --git a/js/src/components/Comment/Comment.vue b/js/src/components/Comment/Comment.vue index 00994462c..2e5fac38a 100644 --- a/js/src/components/Comment/Comment.vue +++ b/js/src/components/Comment/Comment.vue @@ -322,12 +322,14 @@ export default class Comment extends Vue { position: "is-bottom-right", duration: 5000, }); - } catch (e) { - Snackbar.open({ - message: e.message, - type: "is-danger", - position: "is-bottom", - }); + } catch (e: any) { + if (e.message) { + Snackbar.open({ + message: e.message, + type: "is-danger", + position: "is-bottom", + }); + } } } } diff --git a/js/src/components/Comment/CommentTree.vue b/js/src/components/Comment/CommentTree.vue index 816e4073e..baf759e19 100644 --- a/js/src/components/Comment/CommentTree.vue +++ b/js/src/components/Comment/CommentTree.vue @@ -213,7 +213,7 @@ export default class CommentTree extends Vue { // and reset the new comment field this.newComment = new CommentModel(); - } catch (errors) { + } catch (errors: any) { console.error(errors); if (errors.graphQLErrors && errors.graphQLErrors.length > 0) { const error = errors.graphQLErrors[0]; @@ -295,7 +295,7 @@ export default class CommentTree extends Vue { }, }); // this.comments = this.comments.filter(commentItem => commentItem.id !== comment.id); - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); diff --git a/js/src/components/Editor.vue b/js/src/components/Editor.vue index a287cd987..1c9c49e43 100644 --- a/js/src/components/Editor.vue +++ b/js/src/components/Editor.vue @@ -331,7 +331,7 @@ export default class EditorComponent extends Vue { }) .run(); } - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); diff --git a/js/src/components/Group/Invitations.vue b/js/src/components/Group/Invitations.vue index 00ace4703..d872388a2 100644 --- a/js/src/components/Group/Invitations.vue +++ b/js/src/components/Group/Invitations.vue @@ -38,7 +38,7 @@ export default class Invitations extends Vue { if (data) { this.$emit("accept-invitation", data.acceptInvitation); } - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); @@ -60,7 +60,7 @@ export default class Invitations extends Vue { if (data) { this.$emit("reject-invitation", data.rejectInvitation); } - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); diff --git a/js/src/components/Participation/ParticipationWithoutAccount.vue b/js/src/components/Participation/ParticipationWithoutAccount.vue index 0a6410be9..2611190a4 100644 --- a/js/src/components/Participation/ParticipationWithoutAccount.vue +++ b/js/src/components/Participation/ParticipationWithoutAccount.vue @@ -249,7 +249,7 @@ export default class ParticipationWithoutAccount extends Vue { data.joinEvent.metadata.cancellationToken ); } - } catch (e) { + } catch (e: any) { if ( ["TextEncoder is not defined", "crypto.subtle is undefined"].includes( e.message diff --git a/js/src/components/Resource/FolderItem.vue b/js/src/components/Resource/FolderItem.vue index 50c21cfd5..5bf4ae112 100644 --- a/js/src/components/Resource/FolderItem.vue +++ b/js/src/components/Resource/FolderItem.vue @@ -110,7 +110,7 @@ export default class FolderItem extends Mixins(ResourceMixin) { return undefined; } return data.updateResource; - } catch (e) { + } catch (e: any) { Snackbar.open({ message: e.message, type: "is-danger", diff --git a/js/src/components/Settings/NotificationsOnboarding.vue b/js/src/components/Settings/NotificationsOnboarding.vue index 8714bb96d..9df49add3 100644 --- a/js/src/components/Settings/NotificationsOnboarding.vue +++ b/js/src/components/Settings/NotificationsOnboarding.vue @@ -60,7 +60,7 @@ export default class NotificationsOnboarding extends mixins(Onboarding) { async updateSetting(variables: Record): Promise { try { this.doUpdateSetting(variables); - } catch (e) { + } catch (e: any) { Snackbar.open({ message: e.message, type: "is-danger", diff --git a/js/src/components/Todo/CompactTodo.vue b/js/src/components/Todo/CompactTodo.vue index d4476e12c..3f4ebf541 100644 --- a/js/src/components/Todo/CompactTodo.vue +++ b/js/src/components/Todo/CompactTodo.vue @@ -55,7 +55,7 @@ export default class Todo extends Vue { }, }); this.editMode = false; - } catch (e) { + } catch (e: any) { Snackbar.open({ message: e.message, type: "is-danger", diff --git a/js/src/components/Todo/FullTodo.vue b/js/src/components/Todo/FullTodo.vue index c0451b2af..0638beac3 100644 --- a/js/src/components/Todo/FullTodo.vue +++ b/js/src/components/Todo/FullTodo.vue @@ -91,7 +91,7 @@ export default class Todo extends Vue { }, }); this.editMode = false; - } catch (e) { + } catch (e: any) { Snackbar.open({ message: e.message, type: "is-danger", diff --git a/js/src/mixins/event.ts b/js/src/mixins/event.ts index 5f0b28822..f0f426525 100644 --- a/js/src/mixins/event.ts +++ b/js/src/mixins/event.ts @@ -101,7 +101,7 @@ export default class EventMixin extends mixins(Vue) { if (resultData) { this.participationCancelledMessage(); } - } catch (error) { + } catch (error: any) { Snackbar.open({ message: error.message, type: "is-danger", @@ -183,7 +183,7 @@ export default class EventMixin extends mixins(Vue) { position: "is-bottom-right", duration: 5000, }); - } catch (error) { + } catch (error: any) { Snackbar.open({ message: error.message, type: "is-danger", diff --git a/js/src/views/Account/Register.vue b/js/src/views/Account/Register.vue index 95a770e9b..07db71e0d 100644 --- a/js/src/views/Account/Register.vue +++ b/js/src/views/Account/Register.vue @@ -210,7 +210,7 @@ export default class Register extends mixins(identityEditionMixin) { await this.$router.push({ name: RouteName.HOME }); } } - } catch (errorCatched) { + } catch (errorCatched: any) { this.errors = errorCatched.graphQLErrors.reduce( (acc: { [key: string]: string }, error: any) => { acc[error.details || error.field] = error.message; diff --git a/js/src/views/Discussions/Create.vue b/js/src/views/Discussions/Create.vue index f2a0bbc71..3c692e0e7 100644 --- a/js/src/views/Discussions/Create.vue +++ b/js/src/views/Discussions/Create.vue @@ -133,7 +133,7 @@ export default class CreateDiscussion extends Vue { slug: data.createDiscussion.slug, }, }); - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors[0].field == "title") { diff --git a/js/src/views/Group/Create.vue b/js/src/views/Group/Create.vue index ca8863431..6ecfa1959 100644 --- a/js/src/views/Group/Create.vue +++ b/js/src/views/Group/Create.vue @@ -174,7 +174,7 @@ export default class CreateGroup extends mixins(IdentityEditionMixin) { displayName: this.group.displayName(), }) as string ); - } catch (err) { + } catch (err: any) { this.handleError(err); } } diff --git a/js/src/views/Group/Group.vue b/js/src/views/Group/Group.vue index f659406fa..8a867ca1d 100644 --- a/js/src/views/Group/Group.vue +++ b/js/src/views/Group/Group.vue @@ -704,7 +704,7 @@ export default class Group extends mixins(GroupMixin) { }, ], }); - } catch (error) { + } catch (error: any) { if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); } @@ -754,7 +754,7 @@ export default class Group extends mixins(GroupMixin) { this.$notifier.success( this.$t("Group {groupTitle} reported", { groupTitle }) as string ); - } catch (error) { + } catch (error: any) { console.error(error); this.$notifier.error( this.$t("Error while reporting group {groupTitle}", { diff --git a/js/src/views/Group/GroupFollowers.vue b/js/src/views/Group/GroupFollowers.vue index 8fedbfb61..430659792 100644 --- a/js/src/views/Group/GroupFollowers.vue +++ b/js/src/views/Group/GroupFollowers.vue @@ -246,7 +246,7 @@ export default class GroupFollowers extends mixins(GroupMixin) { username: follower.actor.preferredUsername, }); this.$notifier.success(message as string); - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); diff --git a/js/src/views/Group/GroupMembers.vue b/js/src/views/Group/GroupMembers.vue index d4d2697f9..f1b953a1d 100644 --- a/js/src/views/Group/GroupMembers.vue +++ b/js/src/views/Group/GroupMembers.vue @@ -335,7 +335,7 @@ export default class GroupMembers extends mixins(GroupMixin) { }) as string ); this.newMemberUsername = ""; - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.inviteError = error.graphQLErrors[0].message; @@ -402,7 +402,7 @@ export default class GroupMembers extends mixins(GroupMixin) { group: this.group.name || usernameWithDomain(this.group), }) as string ); - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); @@ -458,7 +458,7 @@ export default class GroupMembers extends mixins(GroupMixin) { successMessage = "The member role was updated to simple member"; } this.$notifier.success(this.$t(successMessage) as string); - } catch (error) { + } catch (error: any) { console.error(error); if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); diff --git a/js/src/views/Group/GroupSettings.vue b/js/src/views/Group/GroupSettings.vue index 6ea4e7be3..561c9054e 100644 --- a/js/src/views/Group/GroupSettings.vue +++ b/js/src/views/Group/GroupSettings.vue @@ -238,7 +238,7 @@ export default class GroupSettings extends mixins(GroupMixin) { variables, }); this.$notifier.success(this.$t("Group settings saved") as string); - } catch (err) { + } catch (err: any) { this.handleError(err); } } diff --git a/js/src/views/Group/MyGroups.vue b/js/src/views/Group/MyGroups.vue index 2ae851f77..0066ec85b 100644 --- a/js/src/views/Group/MyGroups.vue +++ b/js/src/views/Group/MyGroups.vue @@ -156,7 +156,7 @@ export default class MyGroups extends Vue { }, ], }); - } catch (error) { + } catch (error: any) { if (error.graphQLErrors && error.graphQLErrors.length > 0) { this.$notifier.error(error.graphQLErrors[0].message); } diff --git a/js/src/views/Posts/Edit.vue b/js/src/views/Posts/Edit.vue index 682bfa2b8..899dc3d72 100644 --- a/js/src/views/Posts/Edit.vue +++ b/js/src/views/Posts/Edit.vue @@ -323,7 +323,7 @@ export default class EditPost extends mixins(GroupMixin) { params: { slug: data.createPost.slug }, }); } - } catch (error) { + } catch (error: any) { console.error(error); this.errors = error.graphQLErrors.reduce( (acc: { [key: string]: any }, localError: any) => { @@ -384,7 +384,7 @@ export default class EditPost extends mixins(GroupMixin) { obj.picture = { mediaId: this.editablePost.picture.id }; } } - } catch (e) { + } catch (e: any) { console.error(e); } return obj; diff --git a/js/src/views/Resources/ResourceFolder.vue b/js/src/views/Resources/ResourceFolder.vue index e38bbacff..360c85892 100644 --- a/js/src/views/Resources/ResourceFolder.vue +++ b/js/src/views/Resources/ResourceFolder.vue @@ -441,7 +441,7 @@ export default class Resources extends Mixins(ResourceMixin) { this.newResource.title = ""; this.newResource.summary = ""; this.newResource.resourceUrl = ""; - } catch (err) { + } catch (err: any) { console.error(err); this.modalError = err.graphQLErrors[0].message; } @@ -461,7 +461,7 @@ export default class Resources extends Mixins(ResourceMixin) { this.newResource.summary = data.previewResourceLink.description; this.newResource.metadata = data.previewResourceLink; this.newResource.type = "link"; - } catch (err) { + } catch (err: any) { console.error(err); this.modalError = err.graphQLErrors[0].message; } @@ -568,7 +568,7 @@ export default class Resources extends Mixins(ResourceMixin) { (id) => id !== resourceID ); delete this.checkedResources[resourceID]; - } catch (e) { + } catch (e: any) { console.error(e); } } @@ -705,7 +705,7 @@ export default class Resources extends Mixins(ResourceMixin) { console.log("Finished adding resource to new parent"); }, }); - } catch (e) { + } catch (e: any) { console.error(e); } } @@ -740,7 +740,7 @@ export default class Resources extends Mixins(ResourceMixin) { params: { path }, query: { ...this.$route.query, ...args }, }); - } catch (e) { + } catch (e: any) { if (isNavigationFailure(e, NavigationFailureType.redirected)) { throw Error(e.toString()); } diff --git a/js/src/views/Settings/AccountSettings.vue b/js/src/views/Settings/AccountSettings.vue index 4063081e3..f26e0b922 100644 --- a/js/src/views/Settings/AccountSettings.vue +++ b/js/src/views/Settings/AccountSettings.vue @@ -303,7 +303,7 @@ export default class AccountSettings extends Vue { ); this.newEmail = ""; this.passwordForEmailChange = ""; - } catch (err) { + } catch (err: any) { this.handleErrors("email", err); } } @@ -325,7 +325,7 @@ export default class AccountSettings extends Vue { this.$notifier.success( this.$t("The password was successfully changed") as string ); - } catch (err) { + } catch (err: any) { this.handleErrors("password", err); } } @@ -359,7 +359,7 @@ export default class AccountSettings extends Vue { }); return await this.$router.push({ name: RouteName.HOME }); - } catch (err) { + } catch (err: any) { this.deletePasswordErrors = err.graphQLErrors.map( ({ message }: GraphQLError) => message ); diff --git a/js/src/views/User/Login.vue b/js/src/views/User/Login.vue index 4965d98d2..27c1e7251 100644 --- a/js/src/views/User/Login.vue +++ b/js/src/views/User/Login.vue @@ -233,7 +233,7 @@ export default class Login extends Vue { } this.$router.push({ name: RouteName.HOME }); return; - } catch (err) { + } catch (err: any) { this.submitted = false; if (err.graphQLErrors) { err.graphQLErrors.forEach(({ message }: { message: string }) => { @@ -257,7 +257,7 @@ export default class Login extends Vue { }); try { await initializeCurrentActor(this.$apollo.provider.defaultClient); - } catch (err) { + } catch (err: any) { if (err instanceof NoIdentitiesException) { await this.$router.push({ name: RouteName.REGISTER_PROFILE, diff --git a/js/src/views/User/PasswordReset.vue b/js/src/views/User/PasswordReset.vue index 37e1c64e8..2987984d6 100644 --- a/js/src/views/User/PasswordReset.vue +++ b/js/src/views/User/PasswordReset.vue @@ -95,7 +95,7 @@ export default class PasswordReset extends Vue { saveUserData(data.resetPassword); this.$router.push({ name: RouteName.HOME }); return; - } catch (err) { + } catch (err: any) { err.graphQLErrors.forEach(({ message }: { message: any }) => { this.errors.push(message); }); diff --git a/js/src/views/User/Register.vue b/js/src/views/User/Register.vue index 72288614c..8d8b10ccb 100644 --- a/js/src/views/User/Register.vue +++ b/js/src/views/User/Register.vue @@ -256,7 +256,7 @@ export default class Register extends Vue { name: RouteName.REGISTER_PROFILE, params: { email: this.credentials.email }, }); - } catch (error) { + } catch (error: any) { console.error(error); this.errors = error.graphQLErrors.reduce( (acc: string[], localError: any) => { diff --git a/js/src/views/User/SendPasswordReset.vue b/js/src/views/User/SendPasswordReset.vue index 2d47d52d1..122df2f16 100644 --- a/js/src/views/User/SendPasswordReset.vue +++ b/js/src/views/User/SendPasswordReset.vue @@ -117,13 +117,15 @@ export default class SendPasswordReset extends Vue { }); this.validationSent = true; - } catch (err) { + } catch (err: any) { console.error(err); - err.graphQLErrors.forEach(({ message }: { message: string }) => { - if (this.errors.indexOf(message) < 0) { - this.errors.push(message); - } - }); + if (err.graphQLErrors) { + err.graphQLErrors.forEach(({ message }: { message: string }) => { + if (this.errors.indexOf(message) < 0) { + this.errors.push(message); + } + }); + } } }