From 1b5ef3152be24972b30fe8b7750358beb623972c Mon Sep 17 00:00:00 2001 From: robario Date: Tue, 29 Jun 2021 12:26:08 +0900 Subject: [PATCH] fix types --- src/helpers/app-store.helper.ts | 8 ++++---- src/helpers/google-play.helper.ts | 10 +++++----- src/helpers/locales.helper.ts | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/helpers/app-store.helper.ts b/src/helpers/app-store.helper.ts index 531c3535..3842ad35 100644 --- a/src/helpers/app-store.helper.ts +++ b/src/helpers/app-store.helper.ts @@ -3,23 +3,23 @@ import { IAppleStoreInfos, IAppleStoreResult } from '../interfaces' import { ResponseHelper } from './' export class AppStoreHelper { - static getAppInfos(bundleID, countryCode?) { + static getAppInfos(bundleID: string, countryCode?: string): Promise { return AppStoreHelper._getLookupFile(bundleID, countryCode) .then(ResponseHelper.handleErrorStatus) .then(response => response.json()) .then(AppStoreHelper._parseResource) } - private static _getLookupFile(bundleID, countryCode?) { + private static _getLookupFile(bundleID: string, countryCode?: string) { return fetch(AppStoreHelper._getItunesLookupUrl(bundleID, countryCode)) } - private static _parseResource(resource: IAppleStoreInfos): IAppleStoreResult { + private static _parseResource(resource: IAppleStoreInfos): IAppleStoreResult | null { if (resource.resultCount === 0) return null return resource.results[0] } - private static _getItunesLookupUrl(bundleId, countryCode?): string { + private static _getItunesLookupUrl(bundleId: string, countryCode?: string): string { let url = `${AppStoreConstants.ITUNES_BASE_URL}/lookup?bundleId=${bundleId}` if (countryCode) { url += `&hl=${countryCode}` diff --git a/src/helpers/google-play.helper.ts b/src/helpers/google-play.helper.ts index 16d7e093..e31be2d7 100644 --- a/src/helpers/google-play.helper.ts +++ b/src/helpers/google-play.helper.ts @@ -3,28 +3,28 @@ import { IGoogleStoreResult } from '../interfaces' import { ResponseHelper } from './' export class GooglePlayHelper { - static getAppInfos(bundleId, countryCode?) { + static getAppInfos(bundleId: string, countryCode?: string): Promise { return GooglePlayHelper._getAppPage(bundleId, countryCode) .then(ResponseHelper.handleErrorStatus) .then(response => response.text()) .then(GooglePlayHelper._parseResource) } - private static _getAppPage(bundleId, countryCode?) { + private static _getAppPage(bundleId: string, countryCode?: string): Promise { return fetch(GooglePlayHelper._getStoreAppUrl(bundleId, countryCode)) } - private static _parseResource(page): IGoogleStoreResult { + private static _parseResource(page: string): IGoogleStoreResult { const infos: any = {} Object.keys(GooglePlayConstants.REGEX).map(key => { // we force a new regex creation to allow multiple calls on the same regex - const regEx = new RegExp(GooglePlayConstants.REGEX[key].source, 'gm').exec(page) + const regEx = new RegExp(GooglePlayConstants.REGEX[key as keyof typeof GooglePlayConstants.REGEX].source, 'gm').exec(page) infos[key.toLowerCase()] = regEx ? regEx[1] : null }) return infos } - private static _getStoreAppUrl(bundleId, countryCode?): string { + private static _getStoreAppUrl(bundleId: string, countryCode?: string): string { let url = `${GooglePlayConstants.PLAY_STORE_ROOT_WEB}?id=${bundleId}` if (countryCode) { url += `&hl=${countryCode}` diff --git a/src/helpers/locales.helper.ts b/src/helpers/locales.helper.ts index f6bc2776..a9018347 100644 --- a/src/helpers/locales.helper.ts +++ b/src/helpers/locales.helper.ts @@ -2,7 +2,7 @@ export class LocalesHelper { static currentLang = 'en' private static _defaultLang = 'en' - private static _translations = { + private static _translations: { [langKey: string]: any; } = { en: require('../i18n/en.json'), fr: require('../i18n/fr.json'), es: require('../i18n/es.json')