Fix a typescript issue with catch variable type

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-09-29 18:20:33 +02:00
parent 7bf745edf7
commit dc52cd042b
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
27 changed files with 87 additions and 75 deletions

View file

@ -209,7 +209,8 @@ export default class Followers extends Mixins(RelayMixin) {
});
await this.$apollo.queries.relayFollowers.refetch();
this.checkedRows = [];
} catch (e) {
} catch (e: any) {
if (e.message) {
Snackbar.open({
message: e.message,
type: "is-danger",
@ -217,6 +218,7 @@ export default class Followers extends Mixins(RelayMixin) {
});
}
}
}
async rejectRelay(address: string): Promise<void> {
try {
@ -228,7 +230,8 @@ export default class Followers extends Mixins(RelayMixin) {
});
await this.$apollo.queries.relayFollowers.refetch();
this.checkedRows = [];
} catch (e) {
} catch (e: any) {
if (e.message) {
Snackbar.open({
message: e.message,
type: "is-danger",
@ -236,6 +239,7 @@ export default class Followers extends Mixins(RelayMixin) {
});
}
}
}
get checkedRowsHaveAtLeastOneToApprove(): boolean {
return this.checkedRows.some((checkedRow) => !checkedRow.approved);
@ -250,7 +254,7 @@ export default class Followers extends Mixins(RelayMixin) {
limit: FOLLOWERS_PER_PAGE,
},
});
} catch (err) {
} catch (err: any) {
console.error(err);
}
}

View file

@ -203,7 +203,7 @@ export default class Followings extends Mixins(RelayMixin) {
limit: FOLLOWINGS_PER_PAGE,
},
});
} catch (err) {
} catch (err: any) {
console.error(err);
}
}
@ -254,7 +254,8 @@ export default class Followings extends Mixins(RelayMixin) {
},
});
this.newRelayAddress = "";
} catch (err) {
} catch (err: any) {
if (err.message) {
Snackbar.open({
message: err.message,
type: "is-danger",
@ -262,6 +263,7 @@ export default class Followings extends Mixins(RelayMixin) {
});
}
}
}
removeRelays(): void {
this.checkedRows.forEach((row: IFollower) => {
@ -295,7 +297,8 @@ export default class Followings extends Mixins(RelayMixin) {
});
await this.$apollo.queries.relayFollowings.refetch();
this.checkedRows = [];
} catch (e) {
} catch (e: any) {
if (e.message) {
Snackbar.open({
message: e.message,
type: "is-danger",
@ -304,4 +307,5 @@ export default class Followings extends Mixins(RelayMixin) {
}
}
}
}
</script>

View file

@ -322,7 +322,8 @@ export default class Comment extends Vue {
position: "is-bottom-right",
duration: 5000,
});
} catch (e) {
} catch (e: any) {
if (e.message) {
Snackbar.open({
message: e.message,
type: "is-danger",
@ -331,6 +332,7 @@ export default class Comment extends Vue {
}
}
}
}
</script>
<style lang="scss" scoped>
form.reply {

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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",

View file

@ -60,7 +60,7 @@ export default class NotificationsOnboarding extends mixins(Onboarding) {
async updateSetting(variables: Record<string, unknown>): Promise<void> {
try {
this.doUpdateSetting(variables);
} catch (e) {
} catch (e: any) {
Snackbar.open({
message: e.message,
type: "is-danger",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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;

View file

@ -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") {

View file

@ -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);
}
}

View file

@ -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}", {

View file

@ -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);

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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());
}

View file

@ -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
);

View file

@ -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,

View file

@ -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);
});

View file

@ -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) => {

View file

@ -117,8 +117,9 @@ export default class SendPasswordReset extends Vue {
});
this.validationSent = true;
} catch (err) {
} catch (err: any) {
console.error(err);
if (err.graphQLErrors) {
err.graphQLErrors.forEach(({ message }: { message: string }) => {
if (this.errors.indexOf(message) < 0) {
this.errors.push(message);
@ -126,6 +127,7 @@ export default class SendPasswordReset extends Vue {
});
}
}
}
resetState(): void {
this.state = {