From 802fb4adaf2e4ffd76b08dc23e29e4c8f4bed543 Mon Sep 17 00:00:00 2001 From: gumi Date: Thu, 19 Aug 2021 12:14:37 -0400 Subject: fix some typescript warnings --- src/App.vue | 2 +- src/components/News.vue | 4 ++-- src/components/ServerStatus.vue | 2 +- src/reCAPTCHA.ts | 11 +++++++---- src/router/redirects.ts | 2 +- src/views/AccountRecovery.vue | 16 ++++++++-------- src/views/Registration.vue | 14 +++++++------- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/App.vue b/src/App.vue index 01632d9..9e4d7b3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -107,7 +107,7 @@ export default class AppV extends Vue { globalStatus = process.env.VUE_APP_STATUS?.trim() ?? ""; - mounted () { + mounted (): void { self.addEventListener("initial-load", () => { this.loaded = true; }); diff --git a/src/components/News.vue b/src/components/News.vue index 3515aa4..ae92d58 100644 --- a/src/components/News.vue +++ b/src/components/News.vue @@ -136,7 +136,7 @@ export default class News extends Vue { private entries: NewsEntry[] = (newsEntries as NewsEntry[]).slice(this.from, this.count); private fullyLoaded = false; - beautify () { + beautify (): void { this.entries.forEach(entry => { // FIXME: weird Vue bug entry.html = entry.html.replace(//g,"

"); @@ -151,7 +151,7 @@ export default class News extends Vue { }); } - mounted () { + mounted (): void { if (!process.env.VUE_APP_NEWS_JSON || !process.env.VUE_APP_NEWS_JSON.startsWith("https")) { this.beautify(); // no extra news to load so end here diff --git a/src/components/ServerStatus.vue b/src/components/ServerStatus.vue index dd4eaa7..c5f6d3c 100644 --- a/src/components/ServerStatus.vue +++ b/src/components/ServerStatus.vue @@ -69,7 +69,7 @@ export default class ServerStatus extends Vue { setTimeout(this.getStatus, 8000); } - mounted () { + mounted (): void { // use the last cached value to populate prior to first fetch: if (Reflect.has(self, "localStorage")) { this.Players = +(localStorage.getItem("onlinePlayers") || 99); diff --git a/src/reCAPTCHA.ts b/src/reCAPTCHA.ts index 51a6350..471cc9b 100644 --- a/src/reCAPTCHA.ts +++ b/src/reCAPTCHA.ts @@ -3,13 +3,16 @@ const loadHandler = "onRecaptchaLoad"; const script = `https://www.google.com/recaptcha/api.js?onload=${loadHandler}`; +// @ts-ignore +type gRecaptchaInstance = any; + export default class ReCaptchaLoader { /** * asynchronously injects reCAPTCHA and resolves once fully loaded * - * @return {Promise} the grecaptcha inferface + * @return {Promise} the grecaptcha inferface */ - static load () { + static load (): Promise { return new Promise((resolve, reject) => { if (Reflect.has(self, "grecaptcha")) { // we already have it loaded: reset it @@ -48,11 +51,11 @@ export default class ReCaptchaLoader { /** * checks whether reCAPTCHA is ready to use */ - static get isReady () { + static get isReady (): boolean { return Reflect.has(self, "grecaptcha"); } - static get instance () { + static get instance (): gRecaptchaInstance { return this.isReady ? Reflect.get(self, "grecaptcha"): null; } } diff --git a/src/router/redirects.ts b/src/router/redirects.ts index 949a531..241abe6 100644 --- a/src/router/redirects.ts +++ b/src/router/redirects.ts @@ -19,7 +19,7 @@ const redirects = [ }, { path: "/downloads.php", - redirect: () => { + redirect: (): void => { self.location.href = "https://manaplus.themanaworld.org/"; } }, diff --git a/src/views/AccountRecovery.vue b/src/views/AccountRecovery.vue index 2eaf0d3..d0ca097 100644 --- a/src/views/AccountRecovery.vue +++ b/src/views/AccountRecovery.vue @@ -179,7 +179,7 @@ export default class Recovery extends Vue { emailToken = ""; recaptcha_key = process.env.VUE_APP_RECAPTCHA; - async mounted () { + async mounted (): Promise { let token: string = document.location.hash.slice(1) as string; if (Reflect.has(this.$route.params, "emailToken")) { @@ -221,7 +221,7 @@ export default class Recovery extends Vue { } } - async start () { + async start (): Promise { this.step = -4; try { @@ -239,16 +239,16 @@ export default class Recovery extends Vue { } } - async checkEmail () { + async checkEmail (): Promise { this.step = reCAPTCHA.isReady ? 2 : -1; // XXX: any actual checks needed here? } - private sleep (milliseconds: number) { + private sleep (milliseconds: number): Promise { return new Promise(resolve => setTimeout(resolve, milliseconds)); } - async confirm () { + async confirm (): Promise { reCAPTCHA.instance.execute(); let token = ""; @@ -323,7 +323,7 @@ export default class Recovery extends Vue { } } - async checkUser () { + async checkUser (): Promise { // TODO: check if the token is valid for this username this.step = reCAPTCHA.isReady ? 5 : -1; await this.$nextTick(); @@ -347,7 +347,7 @@ export default class Recovery extends Vue { return hexCodes.join(""); } - async checkPassword () { + async checkPassword (): Promise { const fullHash = await this.sha1(this.user.pwd); const hashPrefix = fullHash.substring(0, 5); const hashSuffix = fullHash.substring(5); @@ -382,7 +382,7 @@ export default class Recovery extends Vue { } } - async confirm2 () { + async confirm2 (): Promise { reCAPTCHA.instance.execute(); let token = ""; diff --git a/src/views/Registration.vue b/src/views/Registration.vue index 782b072..e170f47 100644 --- a/src/views/Registration.vue +++ b/src/views/Registration.vue @@ -162,7 +162,7 @@ export default class Registration extends Vue { specialEvent = process.env.VUE_APP_EVENT?.trim() ?? ""; // special in-game events - async mounted () { + async mounted (): Promise { // already loaded (user returned to this page) if (reCAPTCHA.isReady) { await this.$nextTick(); @@ -174,7 +174,7 @@ export default class Registration extends Vue { } } - async start () { + async start (): Promise { this.step = -3; try { @@ -187,13 +187,13 @@ export default class Registration extends Vue { } } - async checkEmail () { + async checkEmail (): Promise { this.step = 2; await this.$nextTick(); (this.$refs._user as HTMLInputElement).focus(); } - async checkUser () { + async checkUser (): Promise { // TODO: check here whether the username is taken this.step = 3; await this.$nextTick(); @@ -217,7 +217,7 @@ export default class Registration extends Vue { return hexCodes.join(""); } - async checkPassword () { + async checkPassword (): Promise { const fullHash = await this.sha1(this.user.pwd); const hashPrefix = fullHash.substring(0, 5); const hashSuffix = fullHash.substring(5); @@ -252,11 +252,11 @@ export default class Registration extends Vue { } } - sleep (milliseconds: number) { + sleep (milliseconds: number): Promise { return new Promise(resolve => setTimeout(resolve, milliseconds)); } - async create () { + async create (): Promise { reCAPTCHA.instance.execute(); let token = ""; -- cgit v1.2.3-60-g2f50