Replace any types to more strict types

This commit is contained in:
Christer Warén
2023-06-06 04:58:01 +03:00
parent bc238d919d
commit 3686cd1b0e
7 changed files with 29 additions and 27 deletions

View File

@@ -7,7 +7,7 @@ export interface station {
name: string,
owner: string,
logo: string,
stream: []
stream: any
}
export default class Stations extends Array {
@@ -22,11 +22,11 @@ export default class Stations extends Array {
logger('Stations', 'Started fetching list - ' + options.url);
let list = await fetch(options.url)
.then(this.checkFetchStatus)
.then((response: { json: () => any; }) => response.json());
.then((response: { json: () => station; }) => response.json());
if(list){
this.length = 0;
list.forEach((station: any) => {
list.forEach((station: station) => {
try {
this.push(station);
} catch (error) {
@@ -61,7 +61,7 @@ export default class Stations extends Array {
}
checkFetchStatus(response: any) {
if (response.ok) { // res.status >= 200 && res.status < 300
if (response.ok) {
return response;
} else {
throw new Error(response.status + " " + response.statusText);