Skip to content

Commit 7c9ffdc

Browse files
committed
fix types
1 parent 10d5897 commit 7c9ffdc

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/helpers/app-store.helper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ import { IAppleStoreInfos, IAppleStoreResult } from '../interfaces'
33
import { ResponseHelper } from './'
44

55
export class AppStoreHelper {
6-
static getAppInfos(bundleID, countryCode?) {
6+
static getAppInfos(bundleID: string, countryCode?: string): Promise<IAppleStoreResult | null> {
77
return AppStoreHelper._getLookupFile(bundleID, countryCode)
88
.then(ResponseHelper.handleErrorStatus)
99
.then(response => response.json())
1010
.then(AppStoreHelper._parseResource)
1111
}
1212

13-
private static _getLookupFile(bundleID, countryCode?) {
13+
private static _getLookupFile(bundleID: string, countryCode?: string) {
1414
return fetch(AppStoreHelper._getItunesLookupUrl(bundleID, countryCode))
1515
}
1616

17-
private static _parseResource(resource: IAppleStoreInfos): IAppleStoreResult {
17+
private static _parseResource(resource: IAppleStoreInfos): IAppleStoreResult | null {
1818
if (resource.resultCount === 0) return null
1919
return resource.results[0]
2020
}
2121

22-
private static _getItunesLookupUrl(bundleId, countryCode?): string {
22+
private static _getItunesLookupUrl(bundleId: string, countryCode?: string): string {
2323
let url = `${AppStoreConstants.ITUNES_BASE_URL}/lookup?bundleId=${bundleId}`
2424
if (countryCode) {
2525
url += `&hl=${countryCode}`

src/helpers/google-play.helper.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ import { IGoogleStoreResult } from '../interfaces'
33
import { ResponseHelper } from './'
44

55
export class GooglePlayHelper {
6-
static getAppInfos(bundleId, countryCode?) {
6+
static getAppInfos(bundleId: string, countryCode?: string): Promise<IGoogleStoreResult> {
77
return GooglePlayHelper._getAppPage(bundleId, countryCode)
88
.then(ResponseHelper.handleErrorStatus)
99
.then(response => response.text())
1010
.then(GooglePlayHelper._parseResource)
1111
}
1212

13-
private static _getAppPage(bundleId, countryCode?) {
13+
private static _getAppPage(bundleId: string, countryCode?: string): Promise<Response> {
1414
return fetch(GooglePlayHelper._getStoreAppUrl(bundleId, countryCode))
1515
}
1616

17-
private static _parseResource(page): IGoogleStoreResult {
17+
private static _parseResource(page: string): IGoogleStoreResult {
1818
const infos: any = {}
1919
Object.keys(GooglePlayConstants.REGEX).map(key => {
2020
// we force a new regex creation to allow multiple calls on the same regex
21-
const regEx = new RegExp(GooglePlayConstants.REGEX[key].source, 'gm').exec(page)
21+
const regEx = new RegExp(GooglePlayConstants.REGEX[key as keyof typeof GooglePlayConstants.REGEX].source, 'gm').exec(page)
2222
infos[key.toLowerCase()] = regEx ? regEx[1] : null
2323
})
2424
return infos
2525
}
2626

27-
private static _getStoreAppUrl(bundleId, countryCode?): string {
27+
private static _getStoreAppUrl(bundleId: string, countryCode?: string): string {
2828
let url = `${GooglePlayConstants.PLAY_STORE_ROOT_WEB}?id=${bundleId}`
2929
if (countryCode) {
3030
url += `&hl=${countryCode}`

src/helpers/locales.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export class LocalesHelper {
22
static currentLang = 'en'
33

44
private static _defaultLang = 'en'
5-
private static _translations = {
5+
private static _translations: { [langKey: string]: any; } = {
66
en: require('../i18n/en.json'),
77
fr: require('../i18n/fr.json'),
88
es: require('../i18n/es.json')

src/helpers/response.helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference lib="dom" />
12
export class ResponseHelper {
23
static handleErrorStatus(response: Response): Response {
34
if (response.status >= 400) {

0 commit comments

Comments
 (0)