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

View File

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

View File

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

View File

@ -213,7 +213,7 @@ export default class CommentTree extends Vue {
// and reset the new comment field // and reset the new comment field
this.newComment = new CommentModel(); this.newComment = new CommentModel();
} catch (errors) { } catch (errors: any) {
console.error(errors); console.error(errors);
if (errors.graphQLErrors && errors.graphQLErrors.length > 0) { if (errors.graphQLErrors && errors.graphQLErrors.length > 0) {
const error = errors.graphQLErrors[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); // this.comments = this.comments.filter(commentItem => commentItem.id !== comment.id);
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); this.$notifier.error(error.graphQLErrors[0].message);

View File

@ -331,7 +331,7 @@ export default class EditorComponent extends Vue {
}) })
.run(); .run();
} }
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); this.$notifier.error(error.graphQLErrors[0].message);

View File

@ -38,7 +38,7 @@ export default class Invitations extends Vue {
if (data) { if (data) {
this.$emit("accept-invitation", data.acceptInvitation); this.$emit("accept-invitation", data.acceptInvitation);
} }
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); this.$notifier.error(error.graphQLErrors[0].message);
@ -60,7 +60,7 @@ export default class Invitations extends Vue {
if (data) { if (data) {
this.$emit("reject-invitation", data.rejectInvitation); this.$emit("reject-invitation", data.rejectInvitation);
} }
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); this.$notifier.error(error.graphQLErrors[0].message);

View File

@ -249,7 +249,7 @@ export default class ParticipationWithoutAccount extends Vue {
data.joinEvent.metadata.cancellationToken data.joinEvent.metadata.cancellationToken
); );
} }
} catch (e) { } catch (e: any) {
if ( if (
["TextEncoder is not defined", "crypto.subtle is undefined"].includes( ["TextEncoder is not defined", "crypto.subtle is undefined"].includes(
e.message e.message

View File

@ -110,7 +110,7 @@ export default class FolderItem extends Mixins(ResourceMixin) {
return undefined; return undefined;
} }
return data.updateResource; return data.updateResource;
} catch (e) { } catch (e: any) {
Snackbar.open({ Snackbar.open({
message: e.message, message: e.message,
type: "is-danger", type: "is-danger",

View File

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

View File

@ -55,7 +55,7 @@ export default class Todo extends Vue {
}, },
}); });
this.editMode = false; this.editMode = false;
} catch (e) { } catch (e: any) {
Snackbar.open({ Snackbar.open({
message: e.message, message: e.message,
type: "is-danger", type: "is-danger",

View File

@ -91,7 +91,7 @@ export default class Todo extends Vue {
}, },
}); });
this.editMode = false; this.editMode = false;
} catch (e) { } catch (e: any) {
Snackbar.open({ Snackbar.open({
message: e.message, message: e.message,
type: "is-danger", type: "is-danger",

View File

@ -101,7 +101,7 @@ export default class EventMixin extends mixins(Vue) {
if (resultData) { if (resultData) {
this.participationCancelledMessage(); this.participationCancelledMessage();
} }
} catch (error) { } catch (error: any) {
Snackbar.open({ Snackbar.open({
message: error.message, message: error.message,
type: "is-danger", type: "is-danger",
@ -183,7 +183,7 @@ export default class EventMixin extends mixins(Vue) {
position: "is-bottom-right", position: "is-bottom-right",
duration: 5000, duration: 5000,
}); });
} catch (error) { } catch (error: any) {
Snackbar.open({ Snackbar.open({
message: error.message, message: error.message,
type: "is-danger", type: "is-danger",

View File

@ -210,7 +210,7 @@ export default class Register extends mixins(identityEditionMixin) {
await this.$router.push({ name: RouteName.HOME }); await this.$router.push({ name: RouteName.HOME });
} }
} }
} catch (errorCatched) { } catch (errorCatched: any) {
this.errors = errorCatched.graphQLErrors.reduce( this.errors = errorCatched.graphQLErrors.reduce(
(acc: { [key: string]: string }, error: any) => { (acc: { [key: string]: string }, error: any) => {
acc[error.details || error.field] = error.message; acc[error.details || error.field] = error.message;

View File

@ -133,7 +133,7 @@ export default class CreateDiscussion extends Vue {
slug: data.createDiscussion.slug, slug: data.createDiscussion.slug,
}, },
}); });
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
if (error.graphQLErrors[0].field == "title") { if (error.graphQLErrors[0].field == "title") {

View File

@ -174,7 +174,7 @@ export default class CreateGroup extends mixins(IdentityEditionMixin) {
displayName: this.group.displayName(), displayName: this.group.displayName(),
}) as string }) as string
); );
} catch (err) { } catch (err: any) {
this.handleError(err); 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) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); this.$notifier.error(error.graphQLErrors[0].message);
} }
@ -754,7 +754,7 @@ export default class Group extends mixins(GroupMixin) {
this.$notifier.success( this.$notifier.success(
this.$t("Group {groupTitle} reported", { groupTitle }) as string this.$t("Group {groupTitle} reported", { groupTitle }) as string
); );
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
this.$notifier.error( this.$notifier.error(
this.$t("Error while reporting group {groupTitle}", { this.$t("Error while reporting group {groupTitle}", {

View File

@ -246,7 +246,7 @@ export default class GroupFollowers extends mixins(GroupMixin) {
username: follower.actor.preferredUsername, username: follower.actor.preferredUsername,
}); });
this.$notifier.success(message as string); this.$notifier.success(message as string);
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); this.$notifier.error(error.graphQLErrors[0].message);

View File

@ -335,7 +335,7 @@ export default class GroupMembers extends mixins(GroupMixin) {
}) as string }) as string
); );
this.newMemberUsername = ""; this.newMemberUsername = "";
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.inviteError = error.graphQLErrors[0].message; this.inviteError = error.graphQLErrors[0].message;
@ -402,7 +402,7 @@ export default class GroupMembers extends mixins(GroupMixin) {
group: this.group.name || usernameWithDomain(this.group), group: this.group.name || usernameWithDomain(this.group),
}) as string }) as string
); );
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); 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"; successMessage = "The member role was updated to simple member";
} }
this.$notifier.success(this.$t(successMessage) as string); this.$notifier.success(this.$t(successMessage) as string);
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
if (error.graphQLErrors && error.graphQLErrors.length > 0) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); this.$notifier.error(error.graphQLErrors[0].message);

View File

@ -238,7 +238,7 @@ export default class GroupSettings extends mixins(GroupMixin) {
variables, variables,
}); });
this.$notifier.success(this.$t("Group settings saved") as string); this.$notifier.success(this.$t("Group settings saved") as string);
} catch (err) { } catch (err: any) {
this.handleError(err); 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) { if (error.graphQLErrors && error.graphQLErrors.length > 0) {
this.$notifier.error(error.graphQLErrors[0].message); 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 }, params: { slug: data.createPost.slug },
}); });
} }
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
this.errors = error.graphQLErrors.reduce( this.errors = error.graphQLErrors.reduce(
(acc: { [key: string]: any }, localError: any) => { (acc: { [key: string]: any }, localError: any) => {
@ -384,7 +384,7 @@ export default class EditPost extends mixins(GroupMixin) {
obj.picture = { mediaId: this.editablePost.picture.id }; obj.picture = { mediaId: this.editablePost.picture.id };
} }
} }
} catch (e) { } catch (e: any) {
console.error(e); console.error(e);
} }
return obj; return obj;

View File

@ -441,7 +441,7 @@ export default class Resources extends Mixins(ResourceMixin) {
this.newResource.title = ""; this.newResource.title = "";
this.newResource.summary = ""; this.newResource.summary = "";
this.newResource.resourceUrl = ""; this.newResource.resourceUrl = "";
} catch (err) { } catch (err: any) {
console.error(err); console.error(err);
this.modalError = err.graphQLErrors[0].message; 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.summary = data.previewResourceLink.description;
this.newResource.metadata = data.previewResourceLink; this.newResource.metadata = data.previewResourceLink;
this.newResource.type = "link"; this.newResource.type = "link";
} catch (err) { } catch (err: any) {
console.error(err); console.error(err);
this.modalError = err.graphQLErrors[0].message; this.modalError = err.graphQLErrors[0].message;
} }
@ -568,7 +568,7 @@ export default class Resources extends Mixins(ResourceMixin) {
(id) => id !== resourceID (id) => id !== resourceID
); );
delete this.checkedResources[resourceID]; delete this.checkedResources[resourceID];
} catch (e) { } catch (e: any) {
console.error(e); console.error(e);
} }
} }
@ -705,7 +705,7 @@ export default class Resources extends Mixins(ResourceMixin) {
console.log("Finished adding resource to new parent"); console.log("Finished adding resource to new parent");
}, },
}); });
} catch (e) { } catch (e: any) {
console.error(e); console.error(e);
} }
} }
@ -740,7 +740,7 @@ export default class Resources extends Mixins(ResourceMixin) {
params: { path }, params: { path },
query: { ...this.$route.query, ...args }, query: { ...this.$route.query, ...args },
}); });
} catch (e) { } catch (e: any) {
if (isNavigationFailure(e, NavigationFailureType.redirected)) { if (isNavigationFailure(e, NavigationFailureType.redirected)) {
throw Error(e.toString()); throw Error(e.toString());
} }

View File

@ -303,7 +303,7 @@ export default class AccountSettings extends Vue {
); );
this.newEmail = ""; this.newEmail = "";
this.passwordForEmailChange = ""; this.passwordForEmailChange = "";
} catch (err) { } catch (err: any) {
this.handleErrors("email", err); this.handleErrors("email", err);
} }
} }
@ -325,7 +325,7 @@ export default class AccountSettings extends Vue {
this.$notifier.success( this.$notifier.success(
this.$t("The password was successfully changed") as string this.$t("The password was successfully changed") as string
); );
} catch (err) { } catch (err: any) {
this.handleErrors("password", err); this.handleErrors("password", err);
} }
} }
@ -359,7 +359,7 @@ export default class AccountSettings extends Vue {
}); });
return await this.$router.push({ name: RouteName.HOME }); return await this.$router.push({ name: RouteName.HOME });
} catch (err) { } catch (err: any) {
this.deletePasswordErrors = err.graphQLErrors.map( this.deletePasswordErrors = err.graphQLErrors.map(
({ message }: GraphQLError) => message ({ message }: GraphQLError) => message
); );

View File

@ -233,7 +233,7 @@ export default class Login extends Vue {
} }
this.$router.push({ name: RouteName.HOME }); this.$router.push({ name: RouteName.HOME });
return; return;
} catch (err) { } catch (err: any) {
this.submitted = false; this.submitted = false;
if (err.graphQLErrors) { if (err.graphQLErrors) {
err.graphQLErrors.forEach(({ message }: { message: string }) => { err.graphQLErrors.forEach(({ message }: { message: string }) => {
@ -257,7 +257,7 @@ export default class Login extends Vue {
}); });
try { try {
await initializeCurrentActor(this.$apollo.provider.defaultClient); await initializeCurrentActor(this.$apollo.provider.defaultClient);
} catch (err) { } catch (err: any) {
if (err instanceof NoIdentitiesException) { if (err instanceof NoIdentitiesException) {
await this.$router.push({ await this.$router.push({
name: RouteName.REGISTER_PROFILE, name: RouteName.REGISTER_PROFILE,

View File

@ -95,7 +95,7 @@ export default class PasswordReset extends Vue {
saveUserData(data.resetPassword); saveUserData(data.resetPassword);
this.$router.push({ name: RouteName.HOME }); this.$router.push({ name: RouteName.HOME });
return; return;
} catch (err) { } catch (err: any) {
err.graphQLErrors.forEach(({ message }: { message: any }) => { err.graphQLErrors.forEach(({ message }: { message: any }) => {
this.errors.push(message); this.errors.push(message);
}); });

View File

@ -256,7 +256,7 @@ export default class Register extends Vue {
name: RouteName.REGISTER_PROFILE, name: RouteName.REGISTER_PROFILE,
params: { email: this.credentials.email }, params: { email: this.credentials.email },
}); });
} catch (error) { } catch (error: any) {
console.error(error); console.error(error);
this.errors = error.graphQLErrors.reduce( this.errors = error.graphQLErrors.reduce(
(acc: string[], localError: any) => { (acc: string[], localError: any) => {

View File

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